diff --git a/app/build.gradle.kts b/app/build.gradle.kts index d3e75f743b..a60a194de8 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -23,8 +23,8 @@ android { minSdk = AndroidConfig.minSdkVersion targetSdk = AndroidConfig.targetSdkVersion applicationId = "org.nekomanga.neko" - versionCode = 10 - versionName = "2.16.9" + versionCode = 11 + versionName = "2.16.10" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" multiDexEnabled = true setProperty("archivesBaseName", "Neko") diff --git a/app/src/main/java/eu/kanade/tachiyomi/AppModule.kt b/app/src/main/java/eu/kanade/tachiyomi/AppModule.kt index 7df406c3fc..32cb08ce0a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/AppModule.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/AppModule.kt @@ -177,8 +177,7 @@ class PreferenceModule(val application: Application) : InjektModule { StoragePreferences( context = application, folderProvider = get(), - preferenceStore = get() - ) + preferenceStore = get()) } addSingletonFactory { BackupPreferences(get()) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupCreatorJob.kt b/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupCreatorJob.kt index d645710d63..2bb6597ae5 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupCreatorJob.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupCreatorJob.kt @@ -80,10 +80,7 @@ class BackupCreatorJob(private val context: Context, workerParams: WorkerParamet .build() workManager.enqueueUniquePeriodicWork( - TAG_AUTO, - ExistingPeriodicWorkPolicy.UPDATE, - request - ) + TAG_AUTO, ExistingPeriodicWorkPolicy.UPDATE, request) } } 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 079cb790d4..85ceb492aa 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 @@ -111,9 +111,7 @@ class BackupNotifier(private val context: Context) { R.drawable.ic_close_24dp, context.getString(R.string.stop), NotificationReceiver.cancelRestorePendingBroadcast( - context, - Notifications.ID_RESTORE_PROGRESS - ), + context, Notifications.ID_RESTORE_PROGRESS), ) } 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 e184416b4e..99af3e3f08 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 @@ -127,10 +127,7 @@ class BackupRestorer(val context: Context, val notifier: BackupNotifier) { restoreProgress += 1 totalAmount += 1 restoreHelper.showProgressNotification( - restoreProgress, - totalAmount, - context.getString(R.string.categories) - ) + restoreProgress, totalAmount, context.getString(R.string.categories)) } private fun restoreManga( diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/mappers/MergeMangaTypeMapping.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/mappers/MergeMangaTypeMapping.kt index 5a4ac52d13..e5269f810c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/mappers/MergeMangaTypeMapping.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/mappers/MergeMangaTypeMapping.kt @@ -54,8 +54,7 @@ class MergeMangaGetResolver : DefaultGetResolver() { url = cursor.getString(cursor.getColumnIndex(MergeMangaTable.COL_URL)), mergeType = MergeType.getById( - cursor.getInt(cursor.getColumnIndex(MergeMangaTable.COL_MERGE_TYPE)) - ), + cursor.getInt(cursor.getColumnIndex(MergeMangaTable.COL_MERGE_TYPE))), ) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/queries/HistoryQueries.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/queries/HistoryQueries.kt index ff64faeac7..0ff4f205e4 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/queries/HistoryQueries.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/queries/HistoryQueries.kt @@ -145,8 +145,7 @@ interface HistoryQueries : DbProvider { .rawQuery( RawQuery.builder() .query( - "SELECT SUM(${HistoryTable.COL_TIME_READ}) FROM ${HistoryTable.TABLE}" - ) + "SELECT SUM(${HistoryTable.COL_TIME_READ}) FROM ${HistoryTable.TABLE}") .observesTables(HistoryTable.TABLE) .build(), ) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/queries/MangaCategoryQueries.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/queries/MangaCategoryQueries.kt index 2453fc9e38..8e36a71415 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/queries/MangaCategoryQueries.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/queries/MangaCategoryQueries.kt @@ -22,8 +22,7 @@ interface MangaCategoryQueries : DbProvider { DeleteQuery.builder() .table(MangaCategoryTable.TABLE) .where( - "${MangaCategoryTable.COL_MANGA_ID} IN (${Queries.placeholders(mangaList.size)})" - ) + "${MangaCategoryTable.COL_MANGA_ID} IN (${Queries.placeholders(mangaList.size)})") .whereArgs(*mangaList.map { it.id }.toTypedArray()) .build(), ) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/queries/MangaQueries.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/queries/MangaQueries.kt index 542f968716..29eb1c6f35 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/queries/MangaQueries.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/queries/MangaQueries.kt @@ -103,8 +103,7 @@ interface MangaQueries : DbProvider { db.put() .`object`(manga) .withPutResolver( - MangaFlagsPutResolver(MangaTable.COL_CHAPTER_FLAGS, Manga::chapter_flags) - ) + MangaFlagsPutResolver(MangaTable.COL_CHAPTER_FLAGS, Manga::chapter_flags)) .prepare() fun updateChapterFlags(manga: List) = @@ -129,8 +128,7 @@ interface MangaQueries : DbProvider { db.put() .objects(manga) .withPutResolver( - MangaFlagsPutResolver(MangaTable.COL_VIEWER, Manga::viewer_flags, true) - ) + MangaFlagsPutResolver(MangaTable.COL_VIEWER, Manga::viewer_flags, true)) .prepare() fun updateScanlatorFilterFlag(manga: Manga) = diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/queries/MergeMangaQueries.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/queries/MergeMangaQueries.kt index 4c0a08f072..6b0f956580 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/queries/MergeMangaQueries.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/queries/MergeMangaQueries.kt @@ -40,8 +40,7 @@ interface MergeMangaQueries : DbProvider { DeleteQuery.builder() .table(MergeMangaTable.TABLE) .where( - "${MergeMangaTable.COL_MANGA_ID} = ? AND ${MergeMangaTable.COL_MERGE_TYPE} = ?" - ) + "${MergeMangaTable.COL_MANGA_ID} = ? AND ${MergeMangaTable.COL_MERGE_TYPE} = ?") .whereArgs(mangaId, mergeType.id) .build(), ) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/ChapterSourceOrderPutResolver.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/ChapterSourceOrderPutResolver.kt index 9e151b3bf8..b2428732c0 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/ChapterSourceOrderPutResolver.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/ChapterSourceOrderPutResolver.kt @@ -24,8 +24,7 @@ class ChapterSourceOrderPutResolver : PutResolver() { UpdateQuery.builder() .table(ChapterTable.TABLE) .where( - "${ChapterTable.COL_MANGADEX_CHAPTER_ID} = ? AND ${ChapterTable.COL_MANGA_ID} = ?" - ) + "${ChapterTable.COL_MANGADEX_CHAPTER_ID} = ? AND ${ChapterTable.COL_MANGA_ID} = ?") .whereArgs(chapter.mangadex_chapter_id, chapter.manga_id) .build() diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadCache.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadCache.kt index 04d809ec9f..1f653e598c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadCache.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadCache.kt @@ -82,18 +82,14 @@ class DownloadCache( val fileNames = mangaFiles[manga.id]?.first ?: return false val mangadexIds = mangaFiles[manga.id]?.second ?: return false - if ( - !chapter.isMergedChapter() && - chapter.mangadex_chapter_id.isNotEmpty() && - chapter.mangadex_chapter_id in mangadexIds - ) { + if (!chapter.isMergedChapter() && + chapter.mangadex_chapter_id.isNotEmpty() && + chapter.mangadex_chapter_id in mangadexIds) { return true } - if ( - !chapter.isMergedChapter() && - chapter.old_mangadex_id != null && - chapter.old_mangadex_id in mangadexIds - ) { + if (!chapter.isMergedChapter() && + chapter.old_mangadex_id != null && + chapter.old_mangadex_id in mangadexIds) { return true } @@ -129,13 +125,11 @@ class DownloadCache( files.forEach { if (!MergeType.containsMergeSourceName(it)) { val mangadexId = it.substringAfterLast("- ") - if ( - mangadexId.isNotBlank() && - mangadexId.isDigitsOnly() && - !ids.contains( - mangadexId, - ) - ) { + if (mangadexId.isNotBlank() && + mangadexId.isDigitsOnly() && + !ids.contains( + mangadexId, + )) { count++ } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadJob.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadJob.kt index da02d5baa2..0b08d304d8 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadJob.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadJob.kt @@ -86,8 +86,7 @@ class DownloadJob(val context: Context, workerParameters: WorkerParameters) : !noWifi } else { downloadManager.downloaderStop( - applicationContext.getString(R.string.no_network_connection) - ) + applicationContext.getString(R.string.no_network_connection)) false } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadManager.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadManager.kt index d19be10dcf..edb3af0642 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadManager.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadManager.kt @@ -244,9 +244,8 @@ class DownloadManager(val context: Context) { launchIO { chapterDirs.forEach { it.delete() } - if ( - cache.getDownloadCount(manga, true) == 0 - ) { // Delete manga directory if empty + if (cache.getDownloadCount(manga, true) == + 0) { // Delete manga directory if empty chapterDirs.firstOrNull()?.parentFile?.delete() } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadProvider.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadProvider.kt index 39510c5cd9..6b170a5d84 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadProvider.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadProvider.kt @@ -56,10 +56,7 @@ class DownloadProvider( throw Exception( context.getString( - R.string.invalid_download_location, - downloadsDir?.displayablePath ?: "" - ) - ) + R.string.invalid_download_location, downloadsDir?.displayablePath ?: "")) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt index 620683564f..56a86bfb96 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt @@ -136,6 +136,7 @@ class Downloader( DownloadJob.stop(context) } + /** Pauses the downloader */ fun pause() { cancelDownloaderJob() @@ -410,10 +411,7 @@ class Downloader( page.imageUrl!!, ) -> copyImageFromCache( - chapterCache.getImageFile(page.imageUrl!!), - tmpDir, - filename - ) + chapterCache.getImageFile(page.imageUrl!!), tmpDir, filename) else -> downloadImage(page, download.source, tmpDir, filename) } @@ -524,13 +522,11 @@ class Downloader( val imageFile = tmpDir.listFiles()?.find { it.name!!.startsWith(filename) } ?: throw Error( - context.getString(R.string.download_notifier_split_page_not_found, page.number) - ) + context.getString(R.string.download_notifier_split_page_not_found, page.number)) val imageFilePath = imageFile.filePath ?: throw Error( - context.getString(R.string.download_notifier_split_page_not_found, page.number) - ) + context.getString(R.string.download_notifier_split_page_not_found, page.number)) // check if the original page was previously split before then skip. if (imageFile.name!!.contains("__")) return true @@ -623,10 +619,8 @@ class Downloader( private fun removeFromQueue(download: Download) { _queueState.update { store.remove(download) - if ( - download.status == Download.State.DOWNLOADING || - download.status == Download.State.QUEUE - ) { + if (download.status == Download.State.DOWNLOADING || + download.status == Download.State.QUEUE) { download.status = Download.State.NOT_DOWNLOADED } it - download @@ -638,10 +632,8 @@ class Downloader( val downloads = queue.filter { predicate(it) } store.removeAll(downloads) downloads.forEach { download -> - if ( - download.status == Download.State.DOWNLOADING || - download.status == Download.State.QUEUE - ) { + if (download.status == Download.State.DOWNLOADING || + download.status == Download.State.QUEUE) { download.status = Download.State.NOT_DOWNLOADED } } @@ -661,10 +653,8 @@ class Downloader( private fun clearQueueState() { _queueState.update { it.forEach { download -> - if ( - download.status == Download.State.DOWNLOADING || - download.status == Download.State.QUEUE - ) { + if (download.status == Download.State.DOWNLOADING || + download.status == Download.State.QUEUE) { download.status = Download.State.NOT_DOWNLOADED } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/image/coil/AlternativeMangaCoverFetcher.kt b/app/src/main/java/eu/kanade/tachiyomi/data/image/coil/AlternativeMangaCoverFetcher.kt index 980a0747ff..167fb6516c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/image/coil/AlternativeMangaCoverFetcher.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/image/coil/AlternativeMangaCoverFetcher.kt @@ -46,8 +46,7 @@ class AlternativeMangaCoverFetcher( ArtworkKeyer() .key( Artwork(url = url, inLibrary = false, originalArtwork = "", mangaId = mangaId), - options - ) + options) } val fileScope = CoroutineScope(Job() + Dispatchers.IO) @@ -151,8 +150,7 @@ class AlternativeMangaCoverFetcher( sourceLazy.value.headers .newBuilder() .add("x-request-id", "Neko-" + UUID.randomUUID()) - .build() - ) + .build()) // Support attaching custom data to the network request. .tag(Parameters::class.java, options.parameters) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/image/coil/CoverViewTarget.kt b/app/src/main/java/eu/kanade/tachiyomi/data/image/coil/CoverViewTarget.kt index 05c08ebe61..71514293d6 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/image/coil/CoverViewTarget.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/image/coil/CoverViewTarget.kt @@ -25,9 +25,7 @@ class CoverViewTarget( view.setImageDrawable( view.context.iconicsDrawableLarge( MaterialDesignDx.Icon.gmf_broken_image, - color = android.R.attr.textColorSecondary - ) - ) + color = android.R.attr.textColorSecondary)) } else { val request = ImageRequest.Builder(view.context) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/image/coil/MangaCoverFetcher.kt b/app/src/main/java/eu/kanade/tachiyomi/data/image/coil/MangaCoverFetcher.kt index c33b45a129..82e3b4e863 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/image/coil/MangaCoverFetcher.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/image/coil/MangaCoverFetcher.kt @@ -59,10 +59,8 @@ class MangaCoverFetcher( url = url, inLibrary = inLibrary, originalArtwork = originalThumbnailUrl, - mangaId = mangaId - ), - options - ) + mangaId = mangaId), + options) } val fileScope = CoroutineScope(Job() + Dispatchers.IO) @@ -84,8 +82,7 @@ class MangaCoverFetcher( mangaId = mangaId, inLibrary = inLibrary, originalThumbnail = originalThumbnailUrl, - ogFile = File(url.substringAfter("file://")) - ) + ogFile = File(url.substringAfter("file://"))) fileLoader(File(url.substringAfter("file://"))) } null -> error("Invalid image") @@ -105,8 +102,7 @@ class MangaCoverFetcher( mangaId = mangaId, inLibrary = inLibrary, originalThumbnail = originalThumbnailUrl, - ogFile = customCoverFile - ) + ogFile = customCoverFile) return fileLoader(customCoverFile) } } @@ -119,8 +115,7 @@ class MangaCoverFetcher( mangaId = mangaId, inLibrary = inLibrary, originalThumbnail = originalThumbnailUrl, - ogFile = coverFile - ) + ogFile = coverFile) return fileLoader(coverFile) } var snapshot = readFromDiskCache() @@ -134,8 +129,7 @@ class MangaCoverFetcher( mangaId = mangaId, inLibrary = inLibrary, originalThumbnail = originalThumbnailUrl, - ogFile = snapshotCoverCache - ) + ogFile = snapshotCoverCache) return fileLoader(snapshotCoverCache) } @@ -143,8 +137,7 @@ class MangaCoverFetcher( setRatioAndColorsInScope( mangaId = mangaId, inLibrary = inLibrary, - originalThumbnail = originalThumbnailUrl - ) + originalThumbnail = originalThumbnailUrl) return SourceResult( source = snapshot.toImageSource(), mimeType = "image/*", @@ -161,8 +154,7 @@ class MangaCoverFetcher( setRatioAndColorsInScope( mangaId = mangaId, inLibrary = inLibrary, - originalThumbnail = originalThumbnailUrl - ) + originalThumbnail = originalThumbnailUrl) if (responseCoverCache != null) { return fileLoader(responseCoverCache) } @@ -215,8 +207,7 @@ class MangaCoverFetcher( sourceLazy.value.headers .newBuilder() .add("x-request-id", "Neko-" + UUID.randomUUID()) - .build() - ) + .build()) // Support attaching custom data to the network request. .tag(Parameters::class.java, options.parameters) @@ -309,12 +300,7 @@ class MangaCoverFetcher( ) { fileScope.launch { MangaCoverMetadata.setRatioAndColors( - mangaId, - originalThumbnail, - inLibrary, - ogFile, - force - ) + mangaId, originalThumbnail, inLibrary, ogFile, force) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateJob.kt b/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateJob.kt index fdb7a9b5ef..5b337ed628 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateJob.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateJob.kt @@ -138,10 +138,8 @@ class LibraryUpdateJob(private val context: Context, workerParameters: WorkerPar override suspend fun doWork(): Result { if (WORK_NAME_AUTO in tags) { - if ( - DEVICE_ONLY_ON_WIFI in libraryPreferences.autoUpdateDeviceRestrictions().get() && - !context.isConnectedToWifi() - ) { + if (DEVICE_ONLY_ON_WIFI in libraryPreferences.autoUpdateDeviceRestrictions().get() && + !context.isConnectedToWifi()) { return Result.failure() } // Find a running manual worker. If exists, try again later @@ -243,36 +241,28 @@ class LibraryUpdateJob(private val context: Context, workerParameters: WorkerPar } LibraryPreferences.MANGA_TRACKING_PLAN_TO_READ in restrictions && hasTrackWithGivenStatus( - libraryManga, - context.getString(R.string.follows_plan_to_read) - ) -> { + libraryManga, context.getString(R.string.follows_plan_to_read)) -> { skippedUpdates[libraryManga] = context.getString(R.string.skipped_reason_tracking_plan_to_read) return@filter false } LibraryPreferences.MANGA_TRACKING_DROPPED in restrictions && hasTrackWithGivenStatus( - libraryManga, - context.getString(R.string.follows_dropped) - ) -> { + libraryManga, context.getString(R.string.follows_dropped)) -> { skippedUpdates[libraryManga] = context.getString(R.string.skipped_reason_tracking_dropped) return@filter false } LibraryPreferences.MANGA_TRACKING_ON_HOLD in restrictions && hasTrackWithGivenStatus( - libraryManga, - context.getString(R.string.follows_on_hold) - ) -> { + libraryManga, context.getString(R.string.follows_on_hold)) -> { skippedUpdates[libraryManga] = context.getString(R.string.skipped_reason_tracking_on_hold) return@filter false } LibraryPreferences.MANGA_TRACKING_COMPLETED in restrictions && hasTrackWithGivenStatus( - libraryManga, - context.getString(R.string.follows_completed) - ) -> { + libraryManga, context.getString(R.string.follows_completed)) -> { skippedUpdates[libraryManga] = context.getString(R.string.skipped_reason_tracking_completed) return@filter false @@ -308,8 +298,7 @@ class LibraryUpdateJob(private val context: Context, workerParameters: WorkerPar libraryManga.filter { it.category in categoriesToUpdate }.distinctBy { it.id } } else { categoryIds.addAll( - db.getCategories().executeAsBlocking().mapNotNull { it.id } + 0 - ) + db.getCategories().executeAsBlocking().mapNotNull { it.id } + 0) libraryManga.distinctBy { it.id } } } @@ -419,8 +408,7 @@ class LibraryUpdateJob(private val context: Context, workerParameters: WorkerPar MangaDetailChapterInformation( null, emptyList(), - source.fetchChapterList(manga).getOrThrow { Exception(it.message()) } - ) + source.fetchChapterList(manga).getOrThrow { Exception(it.message()) }) } else { source.fetchMangaAndChapterDetails(manga, true).getOrThrow { Exception(it.message()) @@ -469,9 +457,8 @@ class LibraryUpdateJob(private val context: Context, workerParameters: WorkerPar withIOContext { // dont refresh covers while using cached source - if ( - manga.thumbnail_url != null && libraryPreferences.updateCovers().get() - ) { + if (manga.thumbnail_url != null && + libraryPreferences.updateCovers().get()) { coverCache.deleteFromCache(thumbnailUrl, manga.favorite) // load new covers in background val request = @@ -499,9 +486,8 @@ class LibraryUpdateJob(private val context: Context, workerParameters: WorkerPar withIOContext { val tracks = db.getTracks(manga).executeOnIO().toMutableList() - if ( - tracks.isEmpty() || !tracks.any { it.sync_id == trackManager.mdList.id } - ) { + if (tracks.isEmpty() || + !tracks.any { it.sync_id == trackManager.mdList.id }) { val track = trackManager.mdList.createInitialTracker(manga) db.insertTrack(track).executeAsBlocking() if (mangaDexLoginHelper.isLoggedIn()) { @@ -649,13 +635,9 @@ class LibraryUpdateJob(private val context: Context, workerParameters: WorkerPar } } newUpdates.clear() - if ( - skippedUpdates.isNotEmpty() && - Notifications.isNotificationChannelEnabled( - context, - Notifications.Channel.Library.Skipped - ) - ) { + if (skippedUpdates.isNotEmpty() && + Notifications.isNotificationChannelEnabled( + context, Notifications.Channel.Library.Skipped)) { val skippedFile = writeErrorFile( skippedUpdates, @@ -664,13 +646,9 @@ class LibraryUpdateJob(private val context: Context, workerParameters: WorkerPar .getUriCompat(context) notifier.showUpdateSkippedNotification(skippedUpdates.map { it.key.title }, skippedFile) } - if ( - failedUpdates.isNotEmpty() && - Notifications.isNotificationChannelEnabled( - context, - Notifications.Channel.Library.Error - ) - ) { + if (failedUpdates.isNotEmpty() && + Notifications.isNotificationChannelEnabled( + context, Notifications.Channel.Library.Error)) { val errorFile = writeErrorFile(failedUpdates) notifier.showUpdateErrorNotification( failedUpdates.map { it.key.title }, diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateNotifier.kt b/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateNotifier.kt index 07cd61cb69..c7d8592b65 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateNotifier.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateNotifier.kt @@ -104,8 +104,7 @@ class LibraryUpdateNotifier(private val context: Context) { context .notificationBuilder(Notifications.Channel.Library.Error) { setContentTitle( - context.getString(R.string.notification_update_error, errors.size) - ) + context.getString(R.string.notification_update_error, errors.size)) setContentText(context.getString(R.string.tap_to_see_details)) setStyle( NotificationCompat.BigTextStyle() @@ -144,8 +143,7 @@ class LibraryUpdateNotifier(private val context: Context) { context .notificationBuilder(Notifications.Channel.Library.Skipped) { setContentTitle( - context.getString(R.string.notification_update_skipped, skips.size) - ) + context.getString(R.string.notification_update_skipped, skips.size)) setContentText(context.getString(R.string.tap_to_see_details)) setStyle( NotificationCompat.BigTextStyle() diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateRanker.kt b/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateRanker.kt index acca29bcdf..f601ee9a9d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateRanker.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateRanker.kt @@ -27,9 +27,7 @@ object LibraryUpdateRanker { return Comparator { mangaFirst: Manga, mangaSecond: Manga, -> compareValues( - abs(mangaSecond.next_update - time), - abs(mangaFirst.next_update - time) - ) + abs(mangaSecond.next_update - time), abs(mangaFirst.next_update - time)) } .reversed() } 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 7fb548d7fa..afc128e142 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,8 +23,7 @@ object NotificationHandler { context, -201, intent, - PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE - ) + PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) } /** @@ -41,11 +40,7 @@ object NotificationHandler { 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 - ) + context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT or 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 c274be5424..b641582824 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 @@ -110,10 +110,7 @@ class NotificationReceiver : BroadcastReceiver() { val notificationId = intent.getIntExtra(EXTRA_NOTIFICATION_ID, -1) if (notificationId > -1) { dismissNotification( - context, - notificationId, - intent.getIntExtra(EXTRA_GROUP_ID, 0) - ) + context, notificationId, intent.getIntExtra(EXTRA_GROUP_ID, 0)) } val urls = intent.getStringArrayExtra(EXTRA_CHAPTER_URL) ?: return val mangaId = intent.getLongExtra(EXTRA_MANGA_ID, -1) @@ -652,8 +649,7 @@ class NotificationReceiver : BroadcastReceiver() { context, manga.id.hashCode(), newIntent, - PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE - ) + PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) } /** @@ -687,8 +683,7 @@ class NotificationReceiver : BroadcastReceiver() { context, 0, toLaunch, - PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE - ) + PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) } /** diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/notification/Notifications.kt b/app/src/main/java/eu/kanade/tachiyomi/data/notification/Notifications.kt index 6ee6b54fd3..f5cbf5bd33 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/notification/Notifications.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/notification/Notifications.kt @@ -121,13 +121,9 @@ object Notifications { context.getString(R.string.group_backup_restore), ), NotificationChannelGroup( - Group.Download, - context.getString(R.string.group_downloader) - ), + Group.Download, context.getString(R.string.group_downloader)), NotificationChannelGroup( - GROUP_APP_UPDATES, - context.getString(R.string.app_updates) - ), + GROUP_APP_UPDATES, context.getString(R.string.app_updates)), ) .forEach(context.notificationManager::createNotificationChannelGroup) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt index d697f5dd6a..6fba4b2c01 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt @@ -60,15 +60,11 @@ class PreferencesHelper(val context: Context, val preferenceStore: PreferenceSto fun lightTheme() = this.preferenceStore.getEnum( - Keys.lightTheme, - if (supportsDynamic) Themes.MONET else Themes.DEFAULT - ) + Keys.lightTheme, if (supportsDynamic) Themes.MONET else Themes.DEFAULT) fun darkTheme() = this.preferenceStore.getEnum( - Keys.darkTheme, - if (supportsDynamic) Themes.MONET else Themes.DEFAULT - ) + Keys.darkTheme, if (supportsDynamic) Themes.MONET else Themes.DEFAULT) fun showNavigationOverlayNewUser() = this.preferenceStore.getBoolean(Keys.showNavigationOverlayNewUser, true) @@ -208,8 +204,7 @@ class PreferencesHelper(val context: Context, val preferenceStore: PreferenceSto fun hideBottomNavOnScroll() = this.preferenceStore.getBoolean( - "false_key" - ) // this.preferenceStore.getBoolean(Keys.hideBottomNavOnScroll, false) + "false_key") // this.preferenceStore.getBoolean(Keys.hideBottomNavOnScroll, false) fun sideNavIconAlignment() = this.preferenceStore.getInt(Keys.sideNavIconAlignment, 1) @@ -242,8 +237,7 @@ class PreferencesHelper(val context: Context, val preferenceStore: PreferenceSto fun contentRatingSelections() = this.preferenceStore.getStringSet( Keys.contentRating, - setOf(MdConstants.ContentRating.safe, MdConstants.ContentRating.suggestive) - ) + setOf(MdConstants.ContentRating.safe, MdConstants.ContentRating.suggestive)) fun autoTrackContentRatingSelections() = this.preferenceStore.getStringSet( @@ -252,15 +246,12 @@ class PreferencesHelper(val context: Context, val preferenceStore: PreferenceSto MdConstants.ContentRating.safe, MdConstants.ContentRating.suggestive, MdConstants.ContentRating.erotica, - MdConstants.ContentRating.pornographic - ), + MdConstants.ContentRating.pornographic), ) fun autoAddTracker() = this.preferenceStore.getStringSet( - Keys.autoAddTracker, - setOf(TrackManager.MDLIST.toString()) - ) + Keys.autoAddTracker, setOf(TrackManager.MDLIST.toString())) fun setAutoAddTracker(trackersToAutoAdd: Set) { autoAddTracker().set(trackersToAutoAdd) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/TrackManager.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/TrackManager.kt index ef8ed9bd95..d53f090c13 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/TrackManager.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/TrackManager.kt @@ -42,8 +42,7 @@ class TrackManager(private val context: Context) { myAnimeList.id to myAnimeList, aniList.id to aniList, kitsu.id to kitsu, - mangaUpdates.id to mangaUpdates - ) + mangaUpdates.id to mangaUpdates) fun getService(id: Int) = services[id] diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/TrackService.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/TrackService.kt index 7db900a3f4..99617078aa 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/TrackService.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/TrackService.kt @@ -93,12 +93,10 @@ abstract class TrackService(val id: Int) { if (setToReadStatus && track.status == planningStatus() && track.last_chapter_read != 0f) { track.status = readingStatus() } - if ( - setToComplete && - (!mustReadToComplete || track.status == readingStatus()) && - track.total_chapters != 0 && - track.last_chapter_read.toInt() == track.total_chapters - ) { + if (setToComplete && + (!mustReadToComplete || track.status == readingStatus()) && + track.total_chapters != 0 && + track.last_chapter_read.toInt() == track.total_chapters) { track.status = completedStatus() } } 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 9a186fe1d8..575972b632 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 @@ -122,14 +122,12 @@ class AnilistApi(val client: OkHttpClient, interceptor: AnilistInterceptor) { put( "query", if (manga.anilist_id != null && !wasPreviouslyTracked) findQuery() - else searchQuery() - ) + else searchQuery()) putJsonObject("variables") { put( "query", if (manga.anilist_id != null && !wasPreviouslyTracked) manga.anilist_id - else search - ) + else search) } } with(json) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/mdlist/MdList.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/mdlist/MdList.kt index e13ba4cce9..7832bf7cfe 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/mdlist/MdList.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/mdlist/MdList.kt @@ -77,10 +77,8 @@ class MdList(private val context: Context, id: Int) : TrackService(id) { // network call if (followStatus != FollowStatus.UNFOLLOWED) { - if ( - track.total_chapters != 0 && - track.last_chapter_read.toInt() == track.total_chapters - ) { + if (track.total_chapters != 0 && + track.last_chapter_read.toInt() == track.total_chapters) { track.status = FollowStatus.COMPLETED.int mdex.updateFollowStatus( MdUtil.getMangaUUID(track.tracking_url), diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/updater/AppDownloadInstallJob.kt b/app/src/main/java/eu/kanade/tachiyomi/data/updater/AppDownloadInstallJob.kt index 64d0775fe6..523baaa17e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/updater/AppDownloadInstallJob.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/updater/AppDownloadInstallJob.kt @@ -74,16 +74,12 @@ class AppDownloadInstallJob(private val context: Context, workerParams: WorkerPa val idleRun = inputData.getBoolean(IDLE_RUN, false) val url: String if (idleRun) { - if ( - Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && - !context.packageManager.canRequestPackageInstalls() - ) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && + !context.packageManager.canRequestPackageInstalls()) { return Result.failure() } - if ( - preferences.appShouldAutoUpdate().get() == ONLY_ON_UNMETERED && - context.connectivityManager.isActiveNetworkMetered - ) { + if (preferences.appShouldAutoUpdate().get() == ONLY_ON_UNMETERED && + context.connectivityManager.isActiveNetworkMetered) { return Result.retry() } @@ -164,11 +160,9 @@ class AppDownloadInstallJob(private val context: Context, workerParams: WorkerPa } } catch (error: Exception) { TimberKt.e(error) - if ( - error is CancellationException || - isStopped || - (error is StreamResetException && error.errorCode == ErrorCode.CANCEL) - ) { + if (error is CancellationException || + isStopped || + (error is StreamResetException && error.errorCode == ErrorCode.CANCEL)) { notifier.cancel() } else { notifier.onDownloadError(url) @@ -209,8 +203,7 @@ class AppDownloadInstallJob(private val context: Context, workerParams: WorkerPa context, -10053, newIntent, - PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_MUTABLE - ) + PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_MUTABLE) val statusReceiver = pendingIntent.intentSender session.commit(statusReceiver) notifier.onInstalling() 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 af2b083e7f..82dfe7a3c2 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 @@ -27,10 +27,8 @@ class AppUpdateChecker { doExtrasAfterNewUpdate: Boolean = true, ): AppUpdateResult { // Limit checks to once a day at most - if ( - !isUserPrompt && - Date().time < preferences.lastAppCheck().get() + TimeUnit.DAYS.toMillis(1) - ) { + if (!isUserPrompt && + Date().time < preferences.lastAppCheck().get() + TimeUnit.DAYS.toMillis(1)) { return AppUpdateResult.NoNewUpdate } @@ -53,10 +51,8 @@ class AppUpdateChecker { } } if (doExtrasAfterNewUpdate && result is AppUpdateResult.NewUpdate) { - if ( - Build.VERSION.SDK_INT >= Build.VERSION_CODES.S && - preferences.appShouldAutoUpdate().get() != AppDownloadInstallJob.NEVER - ) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S && + preferences.appShouldAutoUpdate().get() != AppDownloadInstallJob.NEVER) { AppDownloadInstallJob.start(context, null, false, waitUntilIdle = true) } AppUpdateNotifier(context) 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 6144949876..bb21dabe41 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 @@ -78,8 +78,7 @@ internal class AppUpdateNotifier(private val context: Context) { context, releaseUrl.hashCode(), releaseIntent, - PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE - ), + PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE), ) } } @@ -167,9 +166,7 @@ internal class AppUpdateNotifier(private val context: Context) { R.drawable.ic_close_24dp, context.getString(R.string.cancel), NotificationReceiver.dismissNotificationPendingBroadcast( - context, - Notifications.ID_INSTALL - ), + context, Notifications.ID_INSTALL), ) addReleasePageAction() } diff --git a/app/src/main/java/eu/kanade/tachiyomi/jobs/follows/FollowsSyncProcessor.kt b/app/src/main/java/eu/kanade/tachiyomi/jobs/follows/FollowsSyncProcessor.kt index 275c8cb6b0..24619abf11 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/jobs/follows/FollowsSyncProcessor.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/jobs/follows/FollowsSyncProcessor.kt @@ -49,8 +49,7 @@ class FollowsSyncProcessor { .fetchAllFollows() .onFailure { errorNotification( - (it as? ResultError.Generic)?.errorString ?: "Error fetching follows" - ) + (it as? ResultError.Generic)?.errorString ?: "Error fetching follows") } .onSuccess { unfilteredManga -> val listManga = @@ -69,10 +68,7 @@ class FollowsSyncProcessor { val mangaIdsToUpdate = listManga.mapNotNull { networkManga -> updateNotification( - networkManga.title, - count.andIncrement, - listManga.size - ) + networkManga.title, count.andIncrement, listManga.size) var dbManga = db.getManga(networkManga.url, sourceManager.mangaDex.id) .executeAsBlocking() diff --git a/app/src/main/java/eu/kanade/tachiyomi/jobs/follows/StatusSyncJob.kt b/app/src/main/java/eu/kanade/tachiyomi/jobs/follows/StatusSyncJob.kt index c1b2e300be..49b7335e0b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/jobs/follows/StatusSyncJob.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/jobs/follows/StatusSyncJob.kt @@ -92,8 +92,7 @@ class StatusSyncJob( ::errorNotification, ::updateNotificationProgress, ::completeNotificationFromDex, - ::updateManga - ) + ::updateManga) withUIContext { applicationContext.toast( applicationContext.getString( @@ -178,8 +177,7 @@ class StatusSyncJob( val notification = progressNotification .setContentTitle( - errorTxt ?: context.getString(R.string.not_logged_into_mangadex_cannot_sync) - ) + errorTxt ?: context.getString(R.string.not_logged_into_mangadex_cannot_sync)) .setAutoCancel(true) .build() context.notificationManager.notify( diff --git a/app/src/main/java/eu/kanade/tachiyomi/jobs/tracking/TrackSyncProcessor.kt b/app/src/main/java/eu/kanade/tachiyomi/jobs/tracking/TrackSyncProcessor.kt index 2d03766243..7b22b0ca57 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/jobs/tracking/TrackSyncProcessor.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/jobs/tracking/TrackSyncProcessor.kt @@ -43,9 +43,8 @@ class TrackSyncProcessor { if (autoAddTracker.size > 1) { val validContentRatings = preferences.autoTrackContentRatingSelections().get() val contentRating = manga.getContentRating() - if ( - contentRating == null || validContentRatings.contains(contentRating.lowercase()) - ) { + if (contentRating == null || + validContentRatings.contains(contentRating.lowercase())) { autoAddTracker .map { it.toInt() } .map { autoAddTrackerId -> @@ -59,9 +58,7 @@ class TrackSyncProcessor { trackService.toTrackServiceItem() val id = trackManager.getIdFromManga( - trackServiceItem, - manga - ) + trackServiceItem, manga) if (id != null) { val trackResult = trackingCoordinator.searchTrackerNonFlow( @@ -70,8 +67,7 @@ class TrackSyncProcessor { .getService(trackService.id)!! .toTrackServiceItem(), manga, - false - ) + false) when (trackResult) { is TrackingConstants.TrackSearchResult.Success -> { val trackSearchItem = @@ -79,10 +75,8 @@ class TrackSyncProcessor { trackingCoordinator.registerTracking( TrackingConstants.TrackAndService( trackSearchItem.trackItem, - trackServiceItem - ), - manga.id!! - ) + trackServiceItem), + manga.id!!) } else -> Unit } diff --git a/app/src/main/java/eu/kanade/tachiyomi/network/NetworkHelper.kt b/app/src/main/java/eu/kanade/tachiyomi/network/NetworkHelper.kt index 1d2c56446f..8ab7218aef 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/network/NetworkHelper.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/network/NetworkHelper.kt @@ -162,8 +162,7 @@ class NetworkHelper(val context: Context) { .apply { add( HttpHeaders.USER_AGENT, - "Neko ${BuildConfig.VERSION_NAME}" + System.getProperty("http.agent") - ) + "Neko ${BuildConfig.VERSION_NAME}" + System.getProperty("http.agent")) add(HttpHeaders.REFERER, MdConstants.baseUrl) add(HttpHeaders.CONTENT_TYPE, "application/json") } diff --git a/app/src/main/java/eu/kanade/tachiyomi/network/services/MangaDexService.kt b/app/src/main/java/eu/kanade/tachiyomi/network/services/MangaDexService.kt index 7b7c33dfd6..4c63000a1a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/network/services/MangaDexService.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/network/services/MangaDexService.kt @@ -46,15 +46,13 @@ interface MangaDexService { suspend fun recentlyAdded(@QueryMap options: ProxyRetrofitQueryMap): ApiResponse @GET( - "${MdConstants.Api.manga}?&order[followedCount]=desc&includes[]=${MdConstants.Types.coverArt}&hasAvailableChapters=true" - ) + "${MdConstants.Api.manga}?&order[followedCount]=desc&includes[]=${MdConstants.Types.coverArt}&hasAvailableChapters=true") suspend fun popularNewReleases( @QueryMap options: ProxyRetrofitQueryMap ): ApiResponse @GET( - "${MdConstants.Api.manga}/{id}?includes[]=${MdConstants.Types.coverArt}&includes[]=${MdConstants.Types.author}&includes[]=${MdConstants.Types.artist}" - ) + "${MdConstants.Api.manga}/{id}?includes[]=${MdConstants.Types.coverArt}&includes[]=${MdConstants.Types.author}&includes[]=${MdConstants.Types.artist}") suspend fun viewManga(@Path("id") id: String): ApiResponse @GET("${MdConstants.Api.manga}/{id}/aggregate") @@ -78,8 +76,7 @@ interface MangaDexService { @Headers("Cache-Control: no-cache") @GET( - "${MdConstants.Api.manga}/{id}/feed?limit=500&contentRating[]=${MdConstants.ContentRating.safe}&contentRating[]=${MdConstants.ContentRating.suggestive}&contentRating[]=${MdConstants.ContentRating.erotica}&contentRating[]=${MdConstants.ContentRating.pornographic}&includes[]=${MdConstants.Types.scanlator}&order[volume]=desc&order[chapter]=desc" - ) + "${MdConstants.Api.manga}/{id}/feed?limit=500&contentRating[]=${MdConstants.ContentRating.safe}&contentRating[]=${MdConstants.ContentRating.suggestive}&contentRating[]=${MdConstants.ContentRating.erotica}&contentRating[]=${MdConstants.ContentRating.pornographic}&includes[]=${MdConstants.Types.scanlator}&order[volume]=desc&order[chapter]=desc") suspend fun viewChapters( @Path("id") id: String, @Query(value = "translatedLanguage[]") translatedLanguages: List, diff --git a/app/src/main/java/eu/kanade/tachiyomi/network/services/SimilarService.kt b/app/src/main/java/eu/kanade/tachiyomi/network/services/SimilarService.kt index 31e8810dfa..8cb8c4c138 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/network/services/SimilarService.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/network/services/SimilarService.kt @@ -7,8 +7,7 @@ import retrofit2.http.Path interface SimilarService { @GET( - "https://cdn.jsdelivr.net/gh/nekomangaorg/similar-data@main/similar/{uuidTwoDigitPrefix}/{uuidThreeDigitPrefix}.html" - ) + "https://cdn.jsdelivr.net/gh/nekomangaorg/similar-data@main/similar/{uuidTwoDigitPrefix}/{uuidThreeDigitPrefix}.html") suspend fun getSimilarMangaString( @Path("uuidTwoDigitPrefix") uuidTwoDigitPrefix: String, @Path("uuidThreeDigitPrefix") uuidThreeDigitPrefix: String diff --git a/app/src/main/java/eu/kanade/tachiyomi/source/online/MangaDex.kt b/app/src/main/java/eu/kanade/tachiyomi/source/online/MangaDex.kt index b6f51d46e2..9780bb8660 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/source/online/MangaDex.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/source/online/MangaDex.kt @@ -72,17 +72,13 @@ open class MangaDex : HttpSource() { return withIOContext { val response = networkServices.service.randomManga( - preferences.contentRatingSelections().get().toList() - ) + preferences.contentRatingSelections().get().toList()) val result = response.getOrResultError("trying to get random Manga").andThen { Ok( it.data.toSourceManga( - preferences.thumbnailQuality().get(), - useNoCoverUrl = false - ) - ) + preferences.thumbnailQuality().get(), useNoCoverUrl = false)) } return@withIOContext result @@ -149,9 +145,7 @@ open class MangaDex : HttpSource() { Ok( listResults.copy( sourceManga = - listResults.sourceManga.shuffled().toImmutableList() - ) - ) + listResults.sourceManga.shuffled().toImmutableList())) } .bind() } @@ -162,9 +156,7 @@ open class MangaDex : HttpSource() { Ok( listResults.copy( sourceManga = - listResults.sourceManga.shuffled().toImmutableList() - ) - ) + listResults.sourceManga.shuffled().toImmutableList())) } .bind() } @@ -175,9 +167,7 @@ open class MangaDex : HttpSource() { Ok( listResults.copy( sourceManga = - listResults.sourceManga.shuffled().toImmutableList() - ) - ) + listResults.sourceManga.shuffled().toImmutableList())) } .bind() } @@ -190,9 +180,7 @@ open class MangaDex : HttpSource() { ListResults( displayScreenType = DisplayScreenType.PopularNewTitles(), sourceManga = - mangaListPage.sourceManga.shuffled().toImmutableList() - ) - ) + mangaListPage.sourceManga.shuffled().toImmutableList())) } .bind() } @@ -201,15 +189,12 @@ open class MangaDex : HttpSource() { latestChapterHandler .getPage( blockedScanlatorUUIDs = blockedScanlatorUUIDs, - limit = MdConstants.Limits.latestSmaller - ) + limit = MdConstants.Limits.latestSmaller) .andThen { mangaListPage -> Ok( ListResults( displayScreenType = DisplayScreenType.LatestChapters(), - sourceManga = mangaListPage.sourceManga - ) - ) + sourceManga = mangaListPage.sourceManga)) } .bind() } @@ -221,9 +206,7 @@ open class MangaDex : HttpSource() { Ok( ListResults( displayScreenType = DisplayScreenType.RecentlyAdded(), - sourceManga = mangaListPage.sourceManga - ) - ) + sourceManga = mangaListPage.sourceManga)) } .bind() } @@ -234,8 +217,7 @@ open class MangaDex : HttpSource() { seasonal.await(), staffPick.await(), nekoDevPicks.await(), - recentlyAdded.await() - ) + recentlyAdded.await()) } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/source/online/handlers/ArtworkHandler.kt b/app/src/main/java/eu/kanade/tachiyomi/source/online/handlers/ArtworkHandler.kt index de8231c739..da55ffb419 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/source/online/handlers/ArtworkHandler.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/source/online/handlers/ArtworkHandler.kt @@ -35,10 +35,7 @@ class ArtworkHandler { true -> artwork + fetchRestOfArtwork( - mangaUUID, - relationshipDtoList.limit, - relationshipDtoList.total - ) + mangaUUID, relationshipDtoList.limit, relationshipDtoList.total) false -> artwork }.map { SourceArtwork( diff --git a/app/src/main/java/eu/kanade/tachiyomi/source/online/handlers/FollowsHandler.kt b/app/src/main/java/eu/kanade/tachiyomi/source/online/handlers/FollowsHandler.kt index c353940930..64233cabf0 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/source/online/handlers/FollowsHandler.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/source/online/handlers/FollowsHandler.kt @@ -57,9 +57,8 @@ class FollowsHandler { when (mangaListDto.total > mangaListDto.limit) { true -> fetchRestOfFollows( - mangaListDto.limit, - mangaListDto.total - ) + mangaListDto + mangaListDto.limit, mangaListDto.total) + + mangaListDto false -> listOf(mangaListDto) } .map { it.data } @@ -129,9 +128,8 @@ class FollowsHandler { } } - return@withContext when ( - val response = authService.updateReadingStatusForManga(mangaId, readingStatusDto) - ) { + return@withContext when (val response = + authService.updateReadingStatusForManga(mangaId, readingStatusDto)) { is ApiResponse.Failure.Error, is ApiResponse.Failure.Exception -> { response.log("trying to update reading status for manga $mangaId") diff --git a/app/src/main/java/eu/kanade/tachiyomi/source/online/handlers/ImageHandler.kt b/app/src/main/java/eu/kanade/tachiyomi/source/online/handlers/ImageHandler.kt index 2af7dfa577..d146ec549b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/source/online/handlers/ImageHandler.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/source/online/handlers/ImageHandler.kt @@ -81,11 +81,9 @@ class ImageHandler { withNonCancellableContext { reportImageWithResponse(response) } } - if ( - (attempt.getError() != null || !attempt.get()!!.isSuccessful) && - attempt.getError() !is CancellationException && - !request.url.toString().startsWith(MdConstants.cdnUrl) - ) { + if ((attempt.getError() != null || !attempt.get()!!.isSuccessful) && + attempt.getError() !is CancellationException && + !request.url.toString().startsWith(MdConstants.cdnUrl)) { TimberKt.e(attempt.getError()) { "$tag error getting image from at home node falling back to cdn" } @@ -158,11 +156,9 @@ class ImageHandler { val currentTime = Date().time val mdAtHomeServerUrl = - when ( - tokenTracker[page.mangaDexChapterId] != null && - (currentTime - tokenTracker[page.mangaDexChapterId]!!) < - MdConstants.mdAtHomeTokenLifespan - ) { + when (tokenTracker[page.mangaDexChapterId] != null && + (currentTime - tokenTracker[page.mangaDexChapterId]!!) < + MdConstants.mdAtHomeTokenLifespan) { true -> data[0] false -> { TimberKt.d { "$tag Time has expired get new at home url isLogged $isLogged" } diff --git a/app/src/main/java/eu/kanade/tachiyomi/source/online/handlers/LatestChapterHandler.kt b/app/src/main/java/eu/kanade/tachiyomi/source/online/handlers/LatestChapterHandler.kt index 090c4131a0..1f55eb80a9 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/source/online/handlers/LatestChapterHandler.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/source/online/handlers/LatestChapterHandler.kt @@ -104,17 +104,13 @@ class LatestChapterHandler { val chapterName = result[it.id]?.firstOrNull()?.buildChapterName() ?: "" it.toSourceManga( - coverQuality = thumbQuality, - displayText = chapterName - ) + coverQuality = thumbQuality, displayText = chapterName) } Ok( MangaListPage( sourceManga = mangaList.toPersistentList(), - hasNextPage = hasMoreResults - ) - ) + hasNextPage = hasMoreResults)) } } .getOrElse { e -> diff --git a/app/src/main/java/eu/kanade/tachiyomi/source/online/handlers/ListHandler.kt b/app/src/main/java/eu/kanade/tachiyomi/source/online/handlers/ListHandler.kt index 15f3c35098..db5654dc37 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/source/online/handlers/ListHandler.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/source/online/handlers/ListHandler.kt @@ -60,9 +60,7 @@ class ListHandler { ListResults( displayScreenType = DisplayScreenType.List( - listDto.data.attributes.name ?: "", - listUUID - ), + listDto.data.attributes.name ?: "", listUUID), sourceManga = mangaListDto.data .map { it.toSourceManga(coverQuality) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/source/online/handlers/MangaHandler.kt b/app/src/main/java/eu/kanade/tachiyomi/source/online/handlers/MangaHandler.kt index b971058bfe..754baecf49 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/source/online/handlers/MangaHandler.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/source/online/handlers/MangaHandler.kt @@ -96,10 +96,7 @@ class MangaHandler { .await() .andThen { mangaDto -> apiMangaParser.mangaDetailsParse( - mangaDto.data, - stats.await(), - simpleChapters.await() - ) + mangaDto.data, stats.await(), simpleChapters.await()) } .andThen { sManga -> Ok(sManga to artworks.await()) } } @@ -181,8 +178,7 @@ class MangaHandler { mangaUUID, langs, chapterListDto.limit, - chapterListDto.total - ) + chapterListDto.total) false -> chapterListDto.data }, ) diff --git a/app/src/main/java/eu/kanade/tachiyomi/source/online/handlers/PageHandler.kt b/app/src/main/java/eu/kanade/tachiyomi/source/online/handlers/PageHandler.kt index cc227fdffe..a0b37c6911 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/source/online/handlers/PageHandler.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/source/online/handlers/PageHandler.kt @@ -78,8 +78,7 @@ class PageHandler { if (chapterDateNewer) { throw Exception( - "This chapter has no pages, it might not be release yet, try refreshing" - ) + "This chapter has no pages, it might not be release yet, try refreshing") } val atHomeDto = diff --git a/app/src/main/java/eu/kanade/tachiyomi/source/online/handlers/SearchHandler.kt b/app/src/main/java/eu/kanade/tachiyomi/source/online/handlers/SearchHandler.kt index fabc59a5eb..0ce8af4cac 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/source/online/handlers/SearchHandler.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/source/online/handlers/SearchHandler.kt @@ -43,10 +43,7 @@ class SearchHandler { val sourceManga = persistentListOf( mangaDto.data.toSourceManga( - preferencesHelper.thumbnailQuality().get(), - false - ) - ) + preferencesHelper.thumbnailQuality().get(), false)) Ok(MangaListPage(sourceManga = sourceManga, hasNextPage = false)) } } @@ -195,8 +192,7 @@ class SearchHandler { mangaListDto.data .distinctBy { it.id } .map { it.toSourceManga(thumbQuality) } - .toImmutableList() - ), + .toImmutableList()), ) } } @@ -231,9 +227,7 @@ class SearchHandler { mangaListDto.data .mapIndexed { index, dto -> dto.toSourceManga( - thumbQuality, - displayText = "No. ${offset + index + 1}" - ) + thumbQuality, displayText = "No. ${offset + index + 1}") } .toImmutableList(), ), diff --git a/app/src/main/java/eu/kanade/tachiyomi/source/online/handlers/SimilarHandler.kt b/app/src/main/java/eu/kanade/tachiyomi/source/online/handlers/SimilarHandler.kt index 675631eaab..f03c63e2b1 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/source/online/handlers/SimilarHandler.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/source/online/handlers/SimilarHandler.kt @@ -168,9 +168,8 @@ class SimilarHandler { val idPairs = similarDto.matches .mapNotNull { - when ( - it.languages.isEmpty() || it.languages.any { lang -> lang in activeLangs } - ) { + when (it.languages.isEmpty() || + it.languages.any { lang -> lang in activeLangs }) { true -> { val id = it.id val text = String.format("%.2f", 100.0 * it.score) + "% match" @@ -218,10 +217,8 @@ class SimilarHandler { .onFailure { val type = "trying to get Anilist recommendations" this.log(type) - if ( - (this is ApiResponse.Failure.Error && this.statusCode.code == 404) || - this is ApiResponse.Failure.Exception - ) { + if ((this is ApiResponse.Failure.Error && this.statusCode.code == 404) || + this is ApiResponse.Failure.Exception) { this.throws(type) } } @@ -291,10 +288,8 @@ class SimilarHandler { .onFailure { val type = "trying to get MAL similar manga" this.log(type) - if ( - (this is ApiResponse.Failure.Error && this.statusCode.code == 404) || - this is ApiResponse.Failure.Exception - ) { + if ((this is ApiResponse.Failure.Error && this.statusCode.code == 404) || + this is ApiResponse.Failure.Exception) { this.throws(type) } } @@ -359,10 +354,8 @@ class SimilarHandler { .onFailure { val type = "trying to get MU similar manga" this.log(type) - if ( - (this is ApiResponse.Failure.Error && this.statusCode.code == 404) || - this is ApiResponse.Failure.Exception - ) { + if ((this is ApiResponse.Failure.Error && this.statusCode.code == 404) || + this is ApiResponse.Failure.Exception) { this.throws(type) } } @@ -438,8 +431,7 @@ class SimilarHandler { MdConstants.ContentRating.safe, MdConstants.ContentRating.suggestive, MdConstants.ContentRating.erotica, - MdConstants.ContentRating.pornographic - ), + MdConstants.ContentRating.pornographic), ) val responseBody = networkServices.service @@ -454,8 +446,7 @@ class SimilarHandler { if (strictMatch && responseBody.data.size != mangaIds.size) { TimberKt.d { "manga returned doesn't match number of manga expected" } throw Exception( - "Unable to complete response ${responseBody.data.size} of ${mangaIds.size} returned" - ) + "Unable to complete response ${responseBody.data.size} of ${mangaIds.size} returned") } return responseBody } diff --git a/app/src/main/java/eu/kanade/tachiyomi/source/online/handlers/external/BilibiliHandler.kt b/app/src/main/java/eu/kanade/tachiyomi/source/online/handlers/external/BilibiliHandler.kt index a5d6962c8b..a1e456525e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/source/online/handlers/external/BilibiliHandler.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/source/online/handlers/external/BilibiliHandler.kt @@ -86,8 +86,7 @@ class BilibiliHandler { if (result.message.contains("need buy episode")) { throw Exception( - "Chapter is unavailable, requires reading and/or purchasing on BililBili" - ) + "Chapter is unavailable, requires reading and/or purchasing on BililBili") } if (result.code != 0) { return emptyList() diff --git a/app/src/main/java/eu/kanade/tachiyomi/source/online/handlers/external/ComikeyHandler.kt b/app/src/main/java/eu/kanade/tachiyomi/source/online/handlers/external/ComikeyHandler.kt index 3fc438ab79..67546f0d6e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/source/online/handlers/external/ComikeyHandler.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/source/online/handlers/external/ComikeyHandler.kt @@ -96,8 +96,7 @@ class ComikeyHandler { override fun onPageStarted(view: WebView?, url: String?, favicon: Bitmap?) { super.onPageStarted(view, url, favicon) view?.evaluateJavascript( - webviewScript.replace("__interface__", interfaceName) - ) {} + webviewScript.replace("__interface__", interfaceName)) {} } // If you're logged in, the manifest URL sent to the client is not a direct @@ -112,10 +111,8 @@ class ComikeyHandler { ): WebResourceResponse? { val url = request?.url ?: return super.shouldInterceptRequest(view, request) - if ( - url.host != "relay-us.epub.rocks" || - url.path?.endsWith("/manifest") != true - ) { + if (url.host != "relay-us.epub.rocks" || + url.path?.endsWith("/manifest") != true) { return super.shouldInterceptRequest(view, request) } @@ -175,11 +172,9 @@ class ComikeyHandler { .apply { removePathSegment(manifestUrl.pathSize - 1) - if ( - it.alternate.isNotEmpty() && - it.height == 2048 && - it.type == "image/jpeg" - ) { + if (it.alternate.isNotEmpty() && + it.height == 2048 && + it.type == "image/jpeg") { addPathSegments( it.alternate .first { diff --git a/app/src/main/java/eu/kanade/tachiyomi/source/online/merged/komga/Komga.kt b/app/src/main/java/eu/kanade/tachiyomi/source/online/merged/komga/Komga.kt index 1538c5fc16..facb19ecc5 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/source/online/merged/komga/Komga.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/source/online/merged/komga/Komga.kt @@ -153,8 +153,7 @@ class Komga : ReducedHttpSource() { responseBody.use { json .decodeFromString>( - it.string() - ) + it.string()) .content } val r = diff --git a/app/src/main/java/eu/kanade/tachiyomi/source/online/merged/toonily/Toonily.kt b/app/src/main/java/eu/kanade/tachiyomi/source/online/merged/toonily/Toonily.kt index f63bc86aae..a3cd1103bb 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/source/online/merged/toonily/Toonily.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/source/online/merged/toonily/Toonily.kt @@ -68,8 +68,7 @@ class Toonily : ReducedHttpSource() { .add("Referer", baseUrl) .add( "User-Agent", - "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Firefox/102.0$userAgentRandomizer" - ) + "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Firefox/102.0$userAgentRandomizer") .build() private val searchHeaders = @@ -82,9 +81,7 @@ class Toonily : ReducedHttpSource() { POST( "$baseUrl/wp-admin/admin-ajax.php", searchHeaders, - searchFormBuilder(query).build() - ) - ) + searchFormBuilder(query).build())) .await() if (!response.isSuccessful) { response.close() @@ -206,8 +203,7 @@ class Toonily : ReducedHttpSource() { parseChapterDate(it) } ?: parseChapterDate( - element.select("span.chapter-release-date").firstOrNull()?.text() - ) + element.select("span.chapter-release-date").firstOrNull()?.text()) chapter } @@ -220,8 +216,7 @@ class Toonily : ReducedHttpSource() { response.closeQuietly() return document .select( - "div.page-break, li.blocks-gallery-item, .reading-content .text-left:not(:has(.blocks-gallery-item)) img" - ) + "div.page-break, li.blocks-gallery-item, .reading-content .text-left:not(:has(.blocks-gallery-item)) img") .mapIndexed { index, element -> Page( index, diff --git a/app/src/main/java/eu/kanade/tachiyomi/source/online/utils/MdSort.kt b/app/src/main/java/eu/kanade/tachiyomi/source/online/utils/MdSort.kt index b9727688d0..e5cc537058 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/source/online/utils/MdSort.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/source/online/utils/MdSort.kt @@ -13,15 +13,9 @@ enum class MdSort(val displayName: String, val key: String, val state: MangaCons LowestRating("lowest rating", MdConstants.Sort.rating, MangaConstants.SortState.Ascending), MostFollows("Most follows", MdConstants.Sort.followCount, MangaConstants.SortState.Descending), LeastFollows( - "Fewest follows", - MdConstants.Sort.followCount, - MangaConstants.SortState.Ascending - ), + "Fewest follows", MdConstants.Sort.followCount, MangaConstants.SortState.Ascending), RecentlyAdded( - "Recently added", - MdConstants.Sort.createdAt, - MangaConstants.SortState.Descending - ), + "Recently added", MdConstants.Sort.createdAt, MangaConstants.SortState.Descending), OldestAdded("Oldest added", MdConstants.Sort.createdAt, MangaConstants.SortState.Descending), YearAscending("Year asc", MdConstants.Sort.year, MangaConstants.SortState.Ascending), YearDescending("Year desc", MdConstants.Sort.year, MangaConstants.SortState.Descending), diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/base/ExpandedAppBarLayout.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/base/ExpandedAppBarLayout.kt index 35d10baefe..94c1c7e4e7 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/base/ExpandedAppBarLayout.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/base/ExpandedAppBarLayout.kt @@ -144,9 +144,8 @@ constructor(context: Context, attrs: AttributeSet? = null) : AppBarLayout(contex private val minTabletHeight: Int get() { val tabHeight = if (tabsFrameLayout?.isVisible == true) 48.dpToPx else 0 - return if ( - context.isTablet() || (compactSearchMode && toolbarMode == ToolbarState.EXPANDED) - ) { + return if (context.isTablet() || + (compactSearchMode && toolbarMode == ToolbarState.EXPANDED)) { (mainToolbar?.height ?: 0) + paddingTop + tabHeight } else { 0 @@ -395,15 +394,13 @@ constructor(context: Context, attrs: AttributeSet? = null) : AppBarLayout(contex val mainActivity = mainActivity ?: return val useSearchToolbar = mainToolbar.alpha <= 0.025f val idle = RecyclerView.SCROLL_STATE_IDLE - if ( - if (useSearchToolbar) { - -y >= height || - (recyclerView is RecyclerView && recyclerView.scrollState <= idle) || - context.isTablet() - } else { - mainActivity.currentToolbar == searchToolbar - } - ) { + if (if (useSearchToolbar) { + -y >= height || + (recyclerView is RecyclerView && recyclerView.scrollState <= idle) || + context.isTablet() + } else { + mainActivity.currentToolbar == searchToolbar + }) { useSearchToolbarForMenu(useSearchToolbar) } } @@ -466,9 +463,8 @@ constructor(context: Context, attrs: AttributeSet? = null) : AppBarLayout(contex fun useSearchToolbarForMenu(showCardTB: Boolean) { val mainActivity = mainActivity ?: return if (lockYPos) return - if ( - (showCardTB || toolbarMode == ToolbarState.SEARCH_ONLY) && cardFrame?.isVisible == true - ) { + if ((showCardTB || toolbarMode == ToolbarState.SEARCH_ONLY) && + cardFrame?.isVisible == true) { if (mainActivity.currentToolbar != searchToolbar) { mainActivity.setFloatingToolbar(true, showSearchAnyway = true) } else { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/base/MaterialFastScroll.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/base/MaterialFastScroll.kt index 8c08345354..dab525b79f 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/base/MaterialFastScroll.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/base/MaterialFastScroll.kt @@ -41,11 +41,9 @@ constructor(context: Context, attrs: AttributeSet? = null) : FastScroller(contex // Overriding to force a distance moved before scrolling override fun onTouchEvent(event: MotionEvent): Boolean { - if ( - controller?.isDragging == true || - recyclerView.computeVerticalScrollRange() <= - recyclerView.computeVerticalScrollExtent() - ) { + if (controller?.isDragging == true || + recyclerView.computeVerticalScrollRange() <= + recyclerView.computeVerticalScrollExtent()) { return if (startY > -1f || controller?.isDragging == true) { dispatchTouchToRecycler(event) false @@ -56,13 +54,11 @@ constructor(context: Context, attrs: AttributeSet? = null) : FastScroller(contex when (event.action) { MotionEvent.ACTION_DOWN -> { - if ( - if (context.resources.isLTR) { - event.x < handle.x - handle.paddingStart - } else { - event.x > handle.width + handle.paddingStart - } - ) { + if (if (context.resources.isLTR) { + event.x < handle.x - handle.paddingStart + } else { + event.x > handle.width + handle.paddingStart + }) { return false } val y = event.y @@ -155,12 +151,10 @@ constructor(context: Context, attrs: AttributeSet? = null) : FastScroller(contex verticalScrollOffset.toFloat() / (verticalScrollRange - height).toFloat() setBubbleAndHandlePosition(height * proportion) // If scroll amount is small, don't show it - if ( - minimumScrollThreshold == 0 || - dy == 0 || - abs(dy) > minimumScrollThreshold || - scrollbarAnimator.isAnimating - ) { + if (minimumScrollThreshold == 0 || + dy == 0 || + abs(dy) > minimumScrollThreshold || + scrollbarAnimator.isAnimating) { showScrollbar() if (autoHideEnabled) hideScrollbar() } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/category/CategoryHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/category/CategoryHolder.kt index 706f4aa488..9e98a67639 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/category/CategoryHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/category/CategoryHolder.kt @@ -55,8 +55,7 @@ class CategoryHolder(view: View, val adapter: CategoryAdapter) : createCategory = category.order == CREATE_CATEGORY_ORDER if (createCategory) { binding.title.setTextColor( - ContextCompat.getColor(itemView.context, R.color.material_on_background_disabled) - ) + ContextCompat.getColor(itemView.context, R.color.material_on_background_disabled)) regularDrawable = itemView.context.iconicsDrawable(MaterialDesignDx.Icon.gmf_add) binding.image.isVisible = false binding.editButton.setImageDrawable(null) @@ -80,16 +79,14 @@ class CategoryHolder(view: View, val adapter: CategoryAdapter) : binding.editText.requestFocus() binding.editText.selectAll() binding.editButton.setImageDrawable( - ContextCompat.getDrawable(itemView.context, R.drawable.ic_check_24dp) - ) + ContextCompat.getDrawable(itemView.context, R.drawable.ic_check_24dp)) binding.editButton.drawable .mutate() .setTint(itemView.context.getResourceColor(R.attr.colorSecondary)) showKeyboard() if (!createCategory) { binding.reorder.setImageDrawable( - itemView.context.iconicsDrawable(MaterialDesignDx.Icon.gmf_delete) - ) + itemView.context.iconicsDrawable(MaterialDesignDx.Icon.gmf_delete)) binding.reorder.setOnClickListener { adapter.categoryItemListener.onItemDelete(flexibleAdapterPosition) } @@ -98,8 +95,7 @@ class CategoryHolder(view: View, val adapter: CategoryAdapter) : if (!createCategory) { setDragHandleView(binding.reorder) binding.editButton.setImageDrawable( - itemView.context.iconicsDrawableMedium(MaterialDesignDx.Icon.gmf_edit) - ) + itemView.context.iconicsDrawableMedium(MaterialDesignDx.Icon.gmf_edit)) } else { binding.editButton.setImageDrawable(null) binding.reorder.setOnTouchListener { _, _ -> true } @@ -119,12 +115,8 @@ class CategoryHolder(view: View, val adapter: CategoryAdapter) : private fun submitChanges() { if (binding.editText.visibility == View.VISIBLE) { - if ( - adapter.categoryItemListener.onCategoryRename( - flexibleAdapterPosition, - binding.editText.text.toString() - ) - ) { + if (adapter.categoryItemListener.onCategoryRename( + flexibleAdapterPosition, binding.editText.text.toString())) { isEditing(false) if (!createCategory) { binding.title.text = binding.editText.text.toString() diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/category/ManageCategoryDialog.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/category/ManageCategoryDialog.kt index 3fd27465f8..76c0f37c56 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/category/ManageCategoryDialog.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/category/ManageCategoryDialog.kt @@ -77,11 +77,9 @@ class ManageCategoryDialog(bundle: Bundle? = null) : DialogController(bundle) { val categoryExists = categoryExists(text) val category = this.category ?: Category.create(text) if (category.id != 0) { - if ( - text.isNotBlank() && - !categoryExists && - !text.equals(this.category?.name ?: "", true) - ) { + if (text.isNotBlank() && + !categoryExists && + !text.equals(this.category?.name ?: "", true)) { category.name = text if (this.category == null) { val categories = db.getCategories().executeAsBlocking() @@ -103,25 +101,21 @@ class ManageCategoryDialog(bundle: Bundle? = null) : DialogController(bundle) { return false } } - when ( - updatePref( - preferences.downloadNewChaptersInCategories(), - preferences.excludeCategoriesInDownloadNew(), - binding.downloadNew, - ) - ) { + when (updatePref( + preferences.downloadNewChaptersInCategories(), + preferences.excludeCategoriesInDownloadNew(), + binding.downloadNew, + )) { true -> preferences.downloadNewChapters().set(true) false -> preferences.downloadNewChapters().set(false) else -> Unit } - if ( - libraryPreferences.updateInterval().get() > 0 && - updatePref( - libraryPreferences.whichCategoriesToUpdate(), - libraryPreferences.whichCategoriesToExclude(), - binding.includeGlobal, - ) == false - ) { + if (libraryPreferences.updateInterval().get() > 0 && + updatePref( + libraryPreferences.whichCategoriesToUpdate(), + libraryPreferences.whichCategoriesToExclude(), + binding.includeGlobal, + ) == false) { libraryPreferences.updateInterval().set(0) LibraryUpdateJob.setupTask(preferences.context, 0) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadBottomPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadBottomPresenter.kt index f4ac4afd9c..3d11b2f9a5 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadBottomPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadBottomPresenter.kt @@ -73,11 +73,9 @@ class DownloadBottomPresenter : BaseCoroutinePresenter() { } val hasChanged = - if ( - this@DownloadBottomPresenter.items.size != items.size || - this@DownloadBottomPresenter.items.sumOf { it.subItemsCount } != - items.sumOf { it.subItemsCount } - ) { + if (this@DownloadBottomPresenter.items.size != items.size || + this@DownloadBottomPresenter.items.sumOf { it.subItemsCount } != + items.sumOf { it.subItemsCount }) { true } else { val oldItemsIds = diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadBottomSheet.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadBottomSheet.kt index 37dfde49d9..966085f2de 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadBottomSheet.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadBottomSheet.kt @@ -203,8 +203,7 @@ constructor( binding.downloadFab.text = context.getString(if (isRunning) R.string.pause else R.string.resume) binding.downloadFab.setIconResource( - if (isRunning) R.drawable.ic_pause_24dp else R.drawable.ic_play_arrow_24dp - ) + if (isRunning) R.drawable.ic_pause_24dp else R.drawable.ic_play_arrow_24dp) } fun onOptionsItemSelected(item: MenuItem): Boolean { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryBadge.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryBadge.kt index dd3f237eaf..861e613f55 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryBadge.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryBadge.kt @@ -84,8 +84,7 @@ class LibraryBadge @JvmOverloads constructor(context: Context, attrs: AttributeS MaterialShapeDrawable(makeShapeCorners(topStart = radius)).apply { this.fillColor = ColorStateList.valueOf( - context.getResourceColor(R.attr.colorDownloadBadge) - ) + context.getResourceColor(R.attr.colorDownloadBadge)) } binding.unreadText.background = MaterialShapeDrawable(makeShapeCorners(bottomEnd = radius)).apply { @@ -104,8 +103,7 @@ class LibraryBadge @JvmOverloads constructor(context: Context, attrs: AttributeS MaterialShapeDrawable(makeShapeCorners(radius, radius)).apply { this.fillColor = ColorStateList.valueOf( - context.getResourceColor(R.attr.colorDownloadBadge) - ) + context.getResourceColor(R.attr.colorDownloadBadge)) } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryCategoryGestureDetector.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryCategoryGestureDetector.kt index 93dfefdb5e..b800cf99c5 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryCategoryGestureDetector.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryCategoryGestureDetector.kt @@ -82,16 +82,13 @@ class LibraryCategoryGestureDetector(private val controller: LibraryController?) val diffX = e2.x - startingX val recycler = controller.binding.libraryGridRecycler.recycler var moved = false - if ( - abs(diffX) >= abs(diffY) && - abs(diffX) > SWIPE_THRESHOLD * 3 && - abs(velocityX) > SWIPE_VELOCITY_THRESHOLD && - sign(diffX) == sign(velocityX) - ) { + if (abs(diffX) >= abs(diffY) && + abs(diffX) > SWIPE_THRESHOLD * 3 && + abs(velocityX) > SWIPE_VELOCITY_THRESHOLD && + sign(diffX) == sign(velocityX)) { moved = controller.jumpToNextCategory( - (diffX >= 0).xor(controller.binding.root.resources.isLTR) - ) + (diffX >= 0).xor(controller.binding.root.resources.isLTR)) result = true } if (!result || !moved) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt index 2903e52c21..47994e870f 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt @@ -252,10 +252,8 @@ class LibraryController( override fun getSearchTitle(): String? { setSubtitle() return searchTitle( - if ( - libraryPreferences.showSearchSuggestions().get() && - libraryPreferences.searchSuggestions().get().isNotBlank() - ) { + if (libraryPreferences.showSearchSuggestions().get() && + libraryPreferences.searchSuggestions().get().isNotBlank()) { "\"${libraryPreferences.searchSuggestions().get()}\"" } else { view?.context?.getString(R.string.your_library)?.lowercase(Locale.ROOT) @@ -317,12 +315,10 @@ class LibraryController( val currentCategory = getHeader()?.category ?: return if (currentCategory.order != activeCategory) { saveActiveCategory(currentCategory) - if ( - !showCategoryInTitle && - presenter.categories.size > 1 && - dy != 0 && - recyclerView.translationY == 0f - ) { + if (!showCategoryInTitle && + presenter.categories.size > 1 && + dy != 0 && + recyclerView.translationY == 0f) { showCategoryText(currentCategory.name) } } @@ -450,14 +446,12 @@ class LibraryController( } private fun setSubtitle() { - if ( - isBindingInitialized && - !singleCategory && - presenter.showAllCategories && - !binding.headerTitle.text.isNullOrBlank() && - !binding.recyclerCover.isClickable && - isControllerVisible - ) { + if (isBindingInitialized && + !singleCategory && + presenter.showAllCategories && + !binding.headerTitle.text.isNullOrBlank() && + !binding.recyclerCover.isClickable && + isControllerVisible) { activityBinding?.searchToolbar?.subtitle = binding.headerTitle.text.toString() } else { activityBinding?.searchToolbar?.subtitle = null @@ -751,10 +745,8 @@ class LibraryController( category.order, text = category.name + - if ( - adapter.showNumber && - adapter.itemsPerCategory[category.id] != null - ) { + if (adapter.showNumber && + adapter.itemsPerCategory[category.id] != null) { " (${adapter.itemsPerCategory[category.id]})" } else { "" @@ -916,21 +908,18 @@ class LibraryController( true } else { binding.libraryGridRecycler.recycler.scrollToPosition( - if (next) adapter.itemCount - 1 else 0 - ) + if (next) adapter.itemCount - 1 else 0) true } } else { val newOffset = presenter.categories.indexOfFirst { presenter.currentCategory == it.id } + (if (next) 1 else -1) - if ( - if (!next) { - newOffset > -1 - } else { - newOffset < presenter.categories.size - } - ) { + if (if (!next) { + newOffset > -1 + } else { + newOffset < presenter.categories.size + }) { val newCategory = presenter.categories[newOffset] val newOrder = newCategory.order scrollToHeader(newOrder) @@ -1035,11 +1024,9 @@ class LibraryController( override fun getSpanSize(position: Int): Int { if (libraryLayout == LibraryItem.LAYOUT_LIST) return managerSpanCount val item = this@LibraryController.mAdapter?.getItem(position) - return if ( - item is LibraryHeaderItem || - item is SearchGlobalItem || - (item is LibraryItem && item.manga.isBlank()) - ) { + return if (item is LibraryHeaderItem || + item is SearchGlobalItem || + (item is LibraryItem && item.manga.isBlank())) { managerSpanCount } else { 1 @@ -1084,10 +1071,8 @@ class LibraryController( binding.recyclerCover.isFocusable = false singleCategory = presenter.categories.size <= 1 - if ( - binding.libraryGridRecycler.recycler.manager is StaggeredGridLayoutManager && - staggeredBundle != null - ) { + if (binding.libraryGridRecycler.recycler.manager is StaggeredGridLayoutManager && + staggeredBundle != null) { binding.libraryGridRecycler.recycler.manager.onRestoreInstanceState(staggeredBundle) staggeredBundle = null } @@ -1151,8 +1136,7 @@ class LibraryController( listOf( EmptyView.Action(R.string.getting_started_guide) { activity?.openInBrowser( - "https://tachiyomi.org/help/guides/getting-started/#installing-an-extension" - ) + "https://tachiyomi.org/help/guides/getting-started/#installing-an-extension") }, ) } else { @@ -1196,10 +1180,8 @@ class LibraryController( } } - if ( - binding.libraryGridRecycler.recycler.manager is StaggeredGridLayoutManager && - isControllerVisible - ) { + if (binding.libraryGridRecycler.recycler.manager is StaggeredGridLayoutManager && + isControllerVisible) { staggeredObserver = ViewTreeObserver.OnGlobalLayoutListener { binding.libraryGridRecycler.recycler.postOnAnimation { @@ -1215,8 +1197,7 @@ class LibraryController( } } binding.libraryGridRecycler.recycler.viewTreeObserver.addOnGlobalLayoutListener( - staggeredObserver - ) + staggeredObserver) viewScope.launchUI { delay(500) removeStaggeredObserver() @@ -1337,12 +1318,10 @@ class LibraryController( binding.appBar.y = 0f binding.appBar.updateAppBarAfterY(mainRecycler) } - } else if ( - !show && - binding.appBar.compactSearchMode && - binding.appBar.useLargeToolbar && - resources.configuration.screenHeightDp >= 600 - ) { + } else if (!show && + binding.appBar.compactSearchMode && + binding.appBar.useLargeToolbar && + resources.configuration.screenHeightDp >= 600) { binding.appBar.compactSearchMode = false mainRecycler.requestApplyInsets() } @@ -1637,8 +1616,7 @@ class LibraryController( (activity as? MainActivity)?.let { (it.binding.bottomNav ?: it.binding.sideNav!!).selectedItemId = R.id.nav_browse router.setRoot( - BrowseController(query).withFadeTransaction().tag(R.id.nav_browse.toString()) - ) + BrowseController(query).withFadeTransaction().tag(R.id.nav_browse.toString())) } } @@ -1646,11 +1624,9 @@ class LibraryController( val position = viewHolder?.bindingAdapterPosition ?: return binding.swipeRefresh.isEnabled = actionState != ItemTouchHelper.ACTION_STATE_DRAG if (actionState == ItemTouchHelper.ACTION_STATE_DRAG) { - if ( - lastItemPosition != null && - position != lastItemPosition && - lastItem == adapter.getItem(position) - ) { + if (lastItemPosition != null && + position != lastItemPosition && + lastItem == adapter.getItem(position)) { // because for whatever reason you can repeatedly tap on a currently dragging manga adapter.removeSelection(position) (binding.libraryGridRecycler.recycler.findViewHolderForAdapterPosition(position) @@ -1686,10 +1662,8 @@ class LibraryController( // Because padding a recycler causes it to scroll up we have to scroll it back down... wild val fromItem = adapter.getItem(fromPosition) val toItem = adapter.getItem(toPosition) - if ( - binding.libraryGridRecycler.recycler.layoutManager !is StaggeredGridLayoutManager && - ((fromItem is LibraryItem && toItem is LibraryItem) || fromItem == null) - ) { + if (binding.libraryGridRecycler.recycler.layoutManager !is StaggeredGridLayoutManager && + ((fromItem is LibraryItem && toItem is LibraryItem) || fromItem == null)) { binding.libraryGridRecycler.recycler.scrollBy( 0, binding.libraryGridRecycler.recycler.paddingTop, @@ -1933,6 +1907,7 @@ class LibraryController( } return false } + // endregion // region Toolbar options methods @@ -1963,8 +1938,7 @@ class LibraryController( context.getResourceDrawable(R.attr.selectableItemBackgroundBorderless) imageTintList = ColorStateList.valueOf( - context.getResourceColor(R.attr.actionBarTintColor) - ) + context.getResourceColor(R.attr.actionBarTintColor)) compatToolTipText = resources?.getText(R.string.show_all_categories) } }!! @@ -1991,12 +1965,10 @@ class LibraryController( } override fun onActionViewExpand(item: MenuItem?) { - if ( - !binding.recyclerCover.isClickable && - query.isBlank() && - !singleCategory && - presenter.showAllCategories - ) { + if (!binding.recyclerCover.isClickable && + query.isBlank() && + !singleCategory && + presenter.showAllCategories) { showCategories(true) } } @@ -2031,6 +2003,7 @@ class LibraryController( } return true } + // endregion // region Action Mode Methods @@ -2081,6 +2054,7 @@ class LibraryController( } return false } + // endregion override fun onActionItemClicked(mode: ActionMode, item: MenuItem): Boolean { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryGestureDetector.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryGestureDetector.kt index dd1778d6ec..25753f1a32 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryGestureDetector.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryGestureDetector.kt @@ -50,22 +50,18 @@ class LibraryGestureDetector(private val controller: LibraryController) : val animator = controller.binding.categoryHopperFrame.animate().setDuration(150L) animator.translationX(0f) animator.withEndAction { hopperFrame.translationX = 0f } - if ( - abs(diffX) <= abs(diffY) && - abs(diffY) > SWIPE_THRESHOLD && - abs(velocityY) > SWIPE_VELOCITY_THRESHOLD - ) { + if (abs(diffX) <= abs(diffY) && + abs(diffY) > SWIPE_THRESHOLD && + abs(velocityY) > SWIPE_VELOCITY_THRESHOLD) { if (diffY <= 0) { controller.showSheet() } else { controller.binding.filterBottomSheet.filterBottomSheet.sheetBehavior?.hide() } - } else if ( - abs(diffX) >= abs(diffY) && - abs(diffX) > SWIPE_THRESHOLD * 5 && - abs(velocityX) > SWIPE_VELOCITY_THRESHOLD && - sign(diffX) == sign(velocityX) - ) { + } else if (abs(diffX) >= abs(diffY) && + abs(diffX) > SWIPE_THRESHOLD * 5 && + abs(velocityX) > SWIPE_VELOCITY_THRESHOLD && + sign(diffX) == sign(velocityX)) { val hopperGravity = (controller.binding.categoryHopperFrame.layoutParams as CoordinatorLayout.LayoutParams) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryHeaderGestureDetector.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryHeaderGestureDetector.kt index 53c1ab63e4..e07b161af2 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryHeaderGestureDetector.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryHeaderGestureDetector.kt @@ -80,11 +80,9 @@ class LibraryHeaderGestureDetector( binding.rearView.isVisible = false } val x = abs(binding.categoryHeaderLayout.translationX) - if ( - abs(diffX) >= abs(diffY) && - sign(velocityX) == sign(diffX) && - ((x > 30f.dpToPx && abs(velocityX) > 100) || abs(velocityX) > 5000) - ) { + if (abs(diffX) >= abs(diffY) && + sign(velocityX) == sign(diffX) && + ((x > 30f.dpToPx && abs(velocityX) > 100) || abs(velocityX) > 5000)) { header?.addCategoryToUpdate() result = true } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryHeaderHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryHeaderHolder.kt index 3c9352c7b8..ddbb3badfb 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryHeaderHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryHeaderHolder.kt @@ -66,8 +66,7 @@ class LibraryHeaderHolder(val view: View, val adapter: LibraryCategoryAdapter) : runningDrawable.centerRadius = 6f.dpToPx runningDrawable.strokeWidth = 2f.dpToPx runningDrawable.setColorSchemeColors( - itemView.context.getResourceColor(R.attr.colorSecondary) - ) + itemView.context.getResourceColor(R.attr.colorSecondary)) binding.endRefresh.setImageDrawable(progressDrawableEnd) binding.startRefresh.setImageDrawable(progressDrawableStart) @@ -328,9 +327,8 @@ class LibraryHeaderHolder(val view: View, val adapter: LibraryCategoryAdapter) : } } else { val sortingMode = LibrarySort.valueOf(menuId) ?: LibrarySort.Title - if ( - sortingMode != LibrarySort.DragAndDrop && sortingMode == category.sortingMode() - ) { + if (sortingMode != LibrarySort.DragAndDrop && + sortingMode == category.sortingMode()) { onCatSortClicked(category, null) return } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt index 6f97a44d3c..2213108db9 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt @@ -166,11 +166,9 @@ class LibraryPresenter( getLibrary() if (!libraryPreferences.showSearchSuggestions().isSet()) { DelayedLibrarySuggestionsJob.setupTask(context, true) - } else if ( - libraryPreferences.showSearchSuggestions().get() && - Date().time >= - libraryPreferences.lastSearchSuggestion().get() + TimeUnit.HOURS.toMillis(2) - ) { + } else if (libraryPreferences.showSearchSuggestions().get() && + Date().time >= + libraryPreferences.lastSearchSuggestion().get() + TimeUnit.HOURS.toMillis(2)) { // Doing this instead of a job in case the app isn't used often presenterScope.launchIO { setSearchSuggestion(libraryPreferences, db, sourceManager) @@ -181,10 +179,8 @@ class LibraryPresenter( fun getItemCountInCategories(categoryId: Int): Int { val items = sectionedLibraryItems[categoryId] - return if ( - items?.firstOrNull()?.manga?.isHidden() == true || - items?.firstOrNull()?.manga?.isBlank() == true - ) { + return if (items?.firstOrNull()?.manga?.isHidden() == true || + items?.firstOrNull()?.manga?.isBlank() == true) { items.firstOrNull()?.manga?.read ?: 0 } else { sectionedLibraryItems[categoryId]?.size ?: 0 @@ -195,10 +191,8 @@ class LibraryPresenter( fun getLibrary() { if (categories.isEmpty()) { val dbCategories = db.getCategories().executeAsBlocking() - if ( - (dbCategories + Category.createDefault(context)).distinctBy { it.order }.size != - dbCategories.size + 1 - ) { + if ((dbCategories + Category.createDefault(context)).distinctBy { it.order }.size != + dbCategories.size + 1) { reorderCategories(dbCategories) } categories = lastCategories ?: db.getCategories().executeAsBlocking().toMutableList() @@ -411,14 +405,12 @@ class LibraryPresenter( if (filterBookmarked == STATE_EXCLUDE && item.manga.bookmarkCount > 0) return false if (filterMangaType > 0) { - if ( - if (filterMangaType == Manga.TYPE_MANHWA) { - (filterMangaType != item.manga.seriesType() && - filterMangaType != Manga.TYPE_WEBTOON) - } else { - filterMangaType != item.manga.seriesType() - } - ) { + if (if (filterMangaType == Manga.TYPE_MANHWA) { + (filterMangaType != item.manga.seriesType() && + filterMangaType != Manga.TYPE_WEBTOON) + } else { + filterMangaType != item.manga.seriesType() + }) { return false } } @@ -445,11 +437,9 @@ class LibraryPresenter( val hasTrack = loggedServices.any { service -> tracks.any { - if ( - service.isMdList() && - (!loginHelper.isLoggedIn() || - it.status == FollowStatus.UNFOLLOWED.int) - ) { + if (service.isMdList() && + (!loginHelper.isLoggedIn() || + it.status == FollowStatus.UNFOLLOWED.int)) { false } else { it.sync_id == service.id @@ -589,13 +579,11 @@ class LibraryPresenter( LibrarySort.Rating -> { if (i2.manga.rating == null && i1.manga.rating != null) { -1 - } else if ( - i2.manga.rating != null && i1.manga.rating == null - ) { + } else if (i2.manga.rating != null && + i1.manga.rating == null) { 1 - } else if ( - i2.manga.rating == null && i1.manga.rating == null - ) { + } else if (i2.manga.rating == null && + i1.manga.rating == null) { 0 } else { val i2Rating = @@ -746,11 +734,9 @@ class LibraryPresenter( if (libraryIsGrouped) { categories.forEach { category -> val catId = category.id ?: return@forEach - if ( - catId > 0 && - !categorySet.contains(catId) && - (catId !in categoriesHidden || !showAll) - ) { + if (catId > 0 && + !categorySet.contains(catId) && + (catId !in categoriesHidden || !showAll)) { val headerItem = headerItems[catId] if (headerItem != null) { items.add( @@ -867,8 +853,7 @@ class LibraryPresenter( } .map { trackAndService -> trackAndService.second.getGlobalStatus( - trackAndService.first.status - ) + trackAndService.first.status) } .distinct() .map { status -> LibraryItem(manga, makeOrGetHeader(status)) } @@ -878,9 +863,8 @@ class LibraryPresenter( listOf( LibraryItem( manga, - makeOrGetHeader(context.getString(R.string.not_tracked)) - ) - ) + makeOrGetHeader( + context.getString(R.string.not_tracked)))) false -> results } } @@ -969,8 +953,7 @@ class LibraryPresenter( items.add( LibraryItem( LibraryManga.createHide(catId, mergedTitle, mangaToRemove.size), - headerItem - ), + headerItem), ) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/display/LibraryCategoryView.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/display/LibraryCategoryView.kt index eef24841c0..79fac097fb 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/display/LibraryCategoryView.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/display/LibraryCategoryView.kt @@ -33,10 +33,9 @@ class LibraryCategoryView @JvmOverloads constructor(context: Context, attrs: Att controller?.presenter?.getLibrary() } showEmptyCatsFiltering.bindToPreference( - libraryPreferences.showEmptyCategoriesWhileFiltering() - ) { - controller?.presenter?.requestFilterUpdate() - } + libraryPreferences.showEmptyCategoriesWhileFiltering()) { + controller?.presenter?.requestFilterUpdate() + } val hideHopper = min( 2, diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/display/TabbedLibraryDisplaySheet.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/display/TabbedLibraryDisplaySheet.kt index b8cec7278d..e5df9b01dd 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/display/TabbedLibraryDisplaySheet.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/display/TabbedLibraryDisplaySheet.kt @@ -33,8 +33,7 @@ open class TabbedLibraryDisplaySheet(val controller: Controller) : binding.menu.isVisible = controller !is SettingsLibraryController binding.menu.compatToolTipText = context.getString(R.string.more_library_settings) binding.menu.setImageDrawable( - context.contextCompatDrawable(R.drawable.ic_outline_settings_24dp) - ) + context.contextCompatDrawable(R.drawable.ic_outline_settings_24dp)) binding.menu.setOnClickListener { controller.router.pushController(SettingsLibraryController().withFadeTransaction()) dismiss() diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/filter/FilterBottomSheet.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/filter/FilterBottomSheet.kt index b33cb3deee..6ab60ccf7a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/filter/FilterBottomSheet.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/filter/FilterBottomSheet.kt @@ -196,8 +196,7 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri controller?.updateHopperY() if (state == BottomSheetBehavior.STATE_COLLAPSED) { libraryRecyler?.updatePaddingRelative( - bottom = sheetBehavior?.peekHeight ?: 0 + 10.dpToPx + bottomBarHeight - ) + bottom = sheetBehavior?.peekHeight ?: 0 + 10.dpToPx + bottomBarHeight) } if (state == BottomSheetBehavior.STATE_EXPANDED) { binding.pill.alpha = 0f @@ -225,8 +224,7 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri libraryRecyler?.updatePaddingRelative(bottom = value + 10.dpToPx + bottomBarHeight) } else { libraryRecyler?.updatePaddingRelative( - bottom = (minHeight * (1 + trueProgress)).toInt() + bottomBarHeight - ) + bottom = (minHeight * (1 + trueProgress)).toInt() + bottomBarHeight) } } @@ -525,9 +523,7 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri val transition = androidx.transition.AutoTransition() transition.duration = 150 androidx.transition.TransitionManager.beginDelayedTransition( - binding.filterLayout, - transition - ) + binding.filterLayout, transition) reorderFilters() filterItems.forEach { it.reset() } trackers?.let { filterItems.remove(it) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/filter/FilterTagGroup.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/filter/FilterTagGroup.kt index 89d9f16ab4..6ed397aadc 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/filter/FilterTagGroup.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/filter/FilterTagGroup.kt @@ -100,11 +100,9 @@ class FilterTagGroup @JvmOverloads constructor(context: Context, attrs: Attribut } private fun toggleButton(index: Int, callBack: Boolean = true) { - if ( - index < 0 || - itemCount == 0 || - (isActivated && index != buttons.indexOfFirst { it.isActivated }) - ) { + if (index < 0 || + itemCount == 0 || + (isActivated && index != buttons.indexOfFirst { it.isActivated })) { return } if (callBack) { 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 06d4ae85c8..623b90be08 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 @@ -203,10 +203,7 @@ open class MainActivity : BaseActivity() { toolbarHeight + if (includeTabs) 48.dpToPx else 0 } else { binding.appBar.getEstimatedLayout( - includeSearchToolbar, - includeTabs, - includeLargeToolbar - ) + includeSearchToolbar, includeTabs, includeLargeToolbar) } } @@ -330,12 +327,10 @@ open class MainActivity : BaseActivity() { val id = item.itemId val currentController = router.backstack.lastOrNull()?.controller if (!continueSwitchingTabs && currentController is BottomNavBarInterface) { - if ( - !currentController.canChangeTabs { - continueSwitchingTabs = true - this@MainActivity.nav.selectedItemId = id - } - ) { + if (!currentController.canChangeTabs { + continueSwitchingTabs = true + this@MainActivity.nav.selectedItemId = id + }) { return@setOnItemSelectedListener false } } @@ -378,11 +373,9 @@ open class MainActivity : BaseActivity() { binding.searchToolbar.setNavigationOnClickListener { val rootSearchController = router.backstack.lastOrNull()?.controller - if ( - (rootSearchController is RootSearchInterface || - (currentToolbar != binding.searchToolbar && binding.appBar.useLargeToolbar)) && - rootSearchController !is SmallToolbarInterface - ) { + if ((rootSearchController is RootSearchInterface || + (currentToolbar != binding.searchToolbar && binding.appBar.useLargeToolbar)) && + rootSearchController !is SmallToolbarInterface) { binding.searchToolbar.menu.findItem(R.id.action_search)?.expandActionView() } else { onBackPressedDispatcher.onBackPressed() @@ -475,14 +468,12 @@ open class MainActivity : BaseActivity() { if (router.backstackSize == 1) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R && !isPush) { window?.setSoftInputMode( - WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN - ) + WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN) } } else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) { @Suppress("DEPRECATION") window?.setSoftInputMode( - WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE - ) + WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE) } } }, @@ -500,11 +491,9 @@ open class MainActivity : BaseActivity() { securityPreferences.incognitoMode().set(false) // Show changelog if needed - if ( - Migrations.upgrade( - preferences, - ) - ) { + if (Migrations.upgrade( + preferences, + )) { if (!BuildConfig.DEBUG) { content.post { whatsNewSheet().show() } } @@ -533,9 +522,7 @@ open class MainActivity : BaseActivity() { } .launchIn(lifecycleScope) setFloatingToolbar( - canShowFloatingToolbar(router.backstack.lastOrNull()?.controller), - changeBG = false - ) + canShowFloatingToolbar(router.backstack.lastOrNull()?.controller), changeBG = false) } fun reEnableBackPressedCallBack() { @@ -598,13 +585,11 @@ open class MainActivity : BaseActivity() { } else { binding.cardFrame.isVisible || binding.cardFrame.alpha > 0f } - if ( - this::router.isInitialized && - needsAnim && - binding.appBar.useLargeToolbar && - !onSmallerController && - (showSearchAnyway || isAppBarVisible) - ) { + if (this::router.isInitialized && + needsAnim && + binding.appBar.useLargeToolbar && + !onSmallerController && + (showSearchAnyway || isAppBarVisible)) { binding.appBar.background = null searchBarAnimation?.cancel() if (showSearchBar && !binding.cardFrame.isVisible) { @@ -618,10 +603,8 @@ open class MainActivity : BaseActivity() { tA.duration = (abs(binding.cardFrame.alpha - endValue) * 150).roundToLong() searchBarAnimation = tA tA.start() - } else if ( - this::router.isInitialized && - (!binding.appBar.useLargeToolbar || onSmallerController || !isAppBarVisible) - ) { + } else if (this::router.isInitialized && + (!binding.appBar.useLargeToolbar || onSmallerController || !isAppBarVisible)) { binding.cardFrame.alpha = 1f binding.cardFrame.isVisible = showSearchBar } @@ -748,12 +731,10 @@ open class MainActivity : BaseActivity() { } private fun showDLQueueTutorial() { - if ( - router.backstackSize == 1 && - this !is SearchActivity && - downloadManager.queueState.value.isNotEmpty() && - !preferences.shownDownloadQueueTutorial().get() - ) { + if (router.backstackSize == 1 && + this !is SearchActivity && + downloadManager.queueState.value.isNotEmpty() && + !preferences.shownDownloadQueueTutorial().get()) { if (!isBindingInitialized) return val recentsItem = nav.getItemView(R.id.nav_recents) ?: return preferences.shownDownloadQueueTutorial().set(true) @@ -920,11 +901,9 @@ open class MainActivity : BaseActivity() { } private fun pressingBack() { - if ( - Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU && - ViewCompat.getRootWindowInsets(window.decorView) - ?.isVisible(WindowInsetsCompat.Type.ime()) == true - ) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU && + ViewCompat.getRootWindowInsets(window.decorView) + ?.isVisible(WindowInsetsCompat.Type.ime()) == true) { WindowInsetsControllerCompat(window, binding.root).hide(WindowInsetsCompat.Type.ime()) } else if (actionMode != null) { actionMode?.finish() @@ -948,10 +927,8 @@ open class MainActivity : BaseActivity() { protected open fun backPress() { val controller = router.backstack.lastOrNull()?.controller - if ( - if (router.backstackSize == 1) controller?.handleBack() != true - else !router.handleBack() - ) { + if (if (router.backstackSize == 1) controller?.handleBack() != true + else !router.handleBack()) { if (shouldGoToStartingTab()) { goToStartingTab() } @@ -1049,18 +1026,15 @@ open class MainActivity : BaseActivity() { toolbar.menu, true, currentItemsId, - toolbar.menu.children.toList().lastIndex - ) + toolbar.menu.children.toList().lastIndex) } // Done because sometimes ActionMenuItemViews have a width/height of 0 and never update val actionMenuView = toolbar.findChild() - if ( - binding.appBar.isVisible && - toolbar.isVisible && - toolbar.width > 0 && - actionMenuView?.children?.any { it.width == 0 } == true - ) { + if (binding.appBar.isVisible && + toolbar.isVisible && + toolbar.width > 0 && + actionMenuView?.children?.any { it.width == 0 } == true) { actionMenuView.children.forEach { if (it !is ActionMenuItemView) return@forEach it.updateLayoutParams { @@ -1133,12 +1107,7 @@ open class MainActivity : BaseActivity() { oldSubMenu.children.toList().forEachIndexed { index, oldSubMenuItem -> val isSubVisible = oldSubMenuItem.isVisible addOrUpdateMenuItem( - oldSubMenuItem, - menuItem.subMenu!!, - isSubVisible, - currentItemsId, - index - ) + oldSubMenuItem, menuItem.subMenu!!, isSubVisible, currentItemsId, index) if (!isExclusiveCheckable) { isExclusiveCheckable = (oldSubMenuItem as? MenuItemImpl)?.isExclusiveCheckable ?: false @@ -1148,10 +1117,7 @@ open class MainActivity : BaseActivity() { } } menuItem.subMenu?.setGroupCheckable( - oldSubMenu.children.first().groupId, - isCheckable, - isExclusiveCheckable - ) + oldSubMenu.children.first().groupId, isCheckable, isExclusiveCheckable) menuItem.subMenu?.children?.toList()?.forEach { if (!newMenuIds.contains(it.itemId)) { menuItem.subMenu?.removeItem(it.itemId) @@ -1194,8 +1160,7 @@ open class MainActivity : BaseActivity() { ev?.let { gestureDetector?.onTouchEvent(it) (router.backstack.lastOrNull()?.controller as? LibraryController)?.handleGeneralEvent( - it - ) + it) } if (ev?.action == MotionEvent.ACTION_DOWN) { if (snackBar != null && snackBar!!.isShown) { @@ -1206,11 +1171,9 @@ open class MainActivity : BaseActivity() { extraViewForUndo?.getGlobalVisibleRect(extRect) // This way the snackbar will only be dismissed if // the user clicks outside it. - if ( - canDismissSnackBar && - !sRect.contains(ev.x.toInt(), ev.y.toInt()) && - (extRect == null || !extRect.contains(ev.x.toInt(), ev.y.toInt())) - ) { + if (canDismissSnackBar && + !sRect.contains(ev.x.toInt(), ev.y.toInt()) && + (extRect == null || !extRect.contains(ev.x.toInt(), ev.y.toInt()))) { snackBar?.dismiss() snackBar = null extraViewForUndo = null @@ -1403,22 +1366,18 @@ open class MainActivity : BaseActivity() { if (abs(diffX) <= abs(diffY)) { val sheetRect = Rect() nav.getGlobalVisibleRect(sheetRect) - if ( - sheetRect.contains(startingX.toInt(), startingY.toInt()) && - abs(diffY) > Companion.SWIPE_THRESHOLD && - abs(velocityY) > Companion.SWIPE_VELOCITY_THRESHOLD && - diffY <= 0 - ) { + if (sheetRect.contains(startingX.toInt(), startingY.toInt()) && + abs(diffY) > Companion.SWIPE_THRESHOLD && + abs(velocityY) > Companion.SWIPE_VELOCITY_THRESHOLD && + diffY <= 0) { val bottomSheetController = router.backstack.lastOrNull()?.controller as? BottomSheetController bottomSheetController?.showSheet() - } else if ( - nav == binding.sideNav && - sheetRect.contains(startingX.toInt(), startingY.toInt()) && - abs(diffY) > Companion.SWIPE_THRESHOLD && - abs(velocityY) > Companion.SWIPE_VELOCITY_THRESHOLD && - diffY > 0 - ) { + } else if (nav == binding.sideNav && + sheetRect.contains(startingX.toInt(), startingY.toInt()) && + abs(diffY) > Companion.SWIPE_THRESHOLD && + abs(velocityY) > Companion.SWIPE_VELOCITY_THRESHOLD && + diffY > 0) { val bottomSheetController = router.backstack.lastOrNull()?.controller as? BottomSheetController bottomSheetController?.hideSheet() diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/main/SearchActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/main/SearchActivity.kt index 1e297515c3..087fc8ca3a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/main/SearchActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/main/SearchActivity.kt @@ -45,11 +45,9 @@ class SearchActivity : MainActivity() { binding.toolbar.setNavigationOnClickListener { popToRoot() } binding.searchToolbar.setNavigationOnClickListener { val rootSearchController = router.backstack.lastOrNull()?.controller - if ( - (rootSearchController is RootSearchInterface || - (currentToolbar != binding.searchToolbar && binding.appBar.useLargeToolbar)) && - rootSearchController !is SmallToolbarInterface - ) { + if ((rootSearchController is RootSearchInterface || + (currentToolbar != binding.searchToolbar && binding.appBar.useLargeToolbar)) && + rootSearchController !is SmallToolbarInterface) { binding.searchToolbar.menu.findItem(R.id.action_search)?.expandActionView() } else { popToRoot() @@ -216,10 +214,8 @@ class SearchActivity : MainActivity() { SHORTCUT_MANGA, SHORTCUT_MANGA_BACK -> { val extras = intent.extras ?: return false - if ( - intent.action == SHORTCUT_MANGA_BACK && - preferences.openChapterInShortcuts().get() - ) { + if (intent.action == SHORTCUT_MANGA_BACK && + preferences.openChapterInShortcuts().get()) { val mangaId = extras.getLong(MangaDetailController.MANGA_EXTRA) if (mangaId != 0L) { val db = Injekt.get() diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailController.kt index 226298a31a..d755cb3b4b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailController.kt @@ -140,8 +140,7 @@ class MangaDetailController(private val mangaId: Long) : ), similarClick = { router.pushController( - SimilarController(presenter.manga.value!!.uuid()).withFadeTransaction() - ) + SimilarController(presenter.manga.value!!.uuid()).withFadeTransaction()) }, shareClick = { shareManga(context) }, coverActions = @@ -163,15 +162,11 @@ class MangaDetailController(private val mangaId: Long) : ChapterActions( mark = presenter::markChapters, download = { chapterItems, downloadAction -> - if ( - chapterItems.size == 1 && - MdConstants.UnsupportedOfficialScanlators.contains( - chapterItems[0].chapter.scanlator - ) - ) { + if (chapterItems.size == 1 && + MdConstants.UnsupportedOfficialScanlators.contains( + chapterItems[0].chapter.scanlator)) { context.toast( - "${chapterItems[0].chapter.scanlator} not supported, try WebView" - ) + "${chapterItems[0].chapter.scanlator} not supported, try WebView") } else { presenter.downloadChapters(chapterItems, downloadAction) } @@ -203,10 +198,8 @@ class MangaDetailController(private val mangaId: Long) : } private fun openChapter(context: Context, chapter: Chapter) { - if ( - chapter.scanlator != null && - MdConstants.UnsupportedOfficialScanlators.contains(chapter.scanlator) - ) { + if (chapter.scanlator != null && + MdConstants.UnsupportedOfficialScanlators.contains(chapter.scanlator)) { context.toast("${chapter.scanlator} not supported, try WebView") } else { startActivity(ReaderActivity.newIntent(context, presenter.manga.value!!, chapter)) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailPresenter.kt index e8ad0e19eb..79a17d0760 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailPresenter.kt @@ -135,8 +135,7 @@ class MangaDetailPresenter( private val _mangaState = MutableStateFlow( - MangaConstants.MangaScreenMangaState(currentArtwork = Artwork(mangaId = mangaId)) - ) + MangaConstants.MangaScreenMangaState(currentArtwork = Artwork(mangaId = mangaId))) val mangaState: StateFlow = _mangaState.asStateFlow() private val _trackMergeState = MutableStateFlow(MangaConstants.MangaScreenTrackMergeState()) @@ -208,9 +207,7 @@ class MangaDetailPresenter( val altArtwork = createAltArtwork(m, currentArtwork) _mangaState.update { mangaState.copy( - currentArtwork = currentArtwork, - alternativeArtwork = altArtwork - ) + currentArtwork = currentArtwork, alternativeArtwork = altArtwork) } updateChapterFlows() updateFilterFlow() @@ -234,8 +231,7 @@ class MangaDetailPresenter( when (result) { is MangaResult.Error -> { _snackbarState.emit( - SnackbarState(message = result.text, messageRes = result.id) - ) + SnackbarState(message = result.text, messageRes = result.id)) _isRefreshing.value = false } is MangaResult.Success -> { @@ -423,9 +419,7 @@ class MangaDetailPresenter( SnackbarState( message = it.message, fieldRes = service.nameRes(), - messageRes = R.string.error_refreshing_ - ) - ) + messageRes = R.string.error_refreshing_)) } } .onSuccess { track -> db.insertTrack(track).executeOnIO() } @@ -454,8 +448,7 @@ class MangaDetailPresenter( markChapters( chaptersToMarkRead, MangaConstants.MarkAction.Read(), - skipSync = true - ) + skipSync = true) } } } @@ -464,8 +457,7 @@ class MangaDetailPresenter( presenterScope.launch { delay(3000) _snackbarState.emit( - SnackbarState("Error trying to mark chapters read from MangaDex $it") - ) + SnackbarState("Error trying to mark chapters read from MangaDex $it")) } } } @@ -548,9 +540,7 @@ class MangaDetailPresenter( true -> coverCache.getCustomCoverFile(currentManga()).takeIf { it.exists() } ?: coverCache.getCoverFile( - currentManga().thumbnail_url, - currentManga().favorite - ) + currentManga().thumbnail_url, currentManga().favorite) false -> coverCache.getCoverFile(artwork.url) } @@ -653,21 +643,18 @@ class MangaDetailPresenter( coverUrl = it.thumbnail_url ?: "", title = it.title, url = it.url, - mergeType = mergeType - ) + mergeType = mergeType) } _trackMergeState.update { when (mergedMangaResults.isEmpty()) { true -> trackMergeState.value.copy( - mergeSearchResult = MergeSearchResult.NoResult - ) + mergeSearchResult = MergeSearchResult.NoResult) false -> trackMergeState.value.copy( mergeSearchResult = - MergeSearchResult.Success(mergedMangaResults) - ) + MergeSearchResult.Success(mergedMangaResults)) } } } @@ -677,9 +664,7 @@ class MangaDetailPresenter( it.copy( mergeSearchResult = MergeSearchResult.Error( - error.message ?: "Error looking up information" - ) - ) + error.message ?: "Error looking up information")) } } } @@ -705,8 +690,7 @@ class MangaDetailPresenter( _mangaState.update { it.copy( alternativeArtwork = altArtwork.toImmutableList(), - currentArtwork = currentArtwork - ) + currentArtwork = currentArtwork) } } } @@ -716,8 +700,7 @@ class MangaDetailPresenter( url = manga.user_cover ?: "", inLibrary = manga.favorite, originalArtwork = manga.thumbnail_url ?: "", - mangaId = mangaId - ) + mangaId = mangaId) } private fun createAltArtwork(manga: Manga, currentArtwork: Artwork): ImmutableList { @@ -766,9 +749,8 @@ class MangaDetailPresenter( val downloadState = when { downloadManager.isChapterDownloaded( - chapter.toDbChapter(), - currentManga() - ) -> Download.State.DOWNLOADED + chapter.toDbChapter(), currentManga()) -> + Download.State.DOWNLOADED else -> { val download = downloadManager.getQueuedDownloadOrNull(chapter.id) @@ -796,10 +778,8 @@ class MangaDetailPresenter( val allChapterScanlators = allChapters.flatMap { ChapterUtil.getScanlators(it.chapter.scanlator) }.toSet() - if ( - allChapterScanlators.size == 1 && - !currentManga().filtered_scanlators.isNullOrEmpty() - ) { + if (allChapterScanlators.size == 1 && + !currentManga().filtered_scanlators.isNullOrEmpty()) { updateMangaScanlator(emptySet()) } @@ -925,19 +905,15 @@ class MangaDetailPresenter( if (shouldAddAsPlanToRead && isOnline()) { track.status = FollowStatus.PLAN_TO_READ.int trackingCoordinator.updateTrackingService( - track.toTrackItem(), - trackManager.mdList.toTrackServiceItem() - ) + track.toTrackItem(), trackManager.mdList.toTrackServiceItem()) } } if (autoAddTracker.size > 1 && currentManga().favorite) { val validContentRatings = preferences.autoTrackContentRatingSelections().get() val contentRating = currentManga().getContentRating() - if ( - (contentRating == null) || - validContentRatings.contains(contentRating.lowercase()) - ) { + if ((contentRating == null) || + validContentRatings.contains(contentRating.lowercase())) { autoAddTracker .map { it.toInt() } .map { autoAddTrackerId -> @@ -947,23 +923,17 @@ class MangaDetailPresenter( ?.let { trackService -> val id = trackManager.getIdFromManga( - trackService, - currentManga() - ) - if ( - id != null && - !trackMergeState.value.tracks.any { - trackService.id == it.trackServiceId - } - ) { + trackService, currentManga()) + if (id != null && + !trackMergeState.value.tracks.any { + trackService.id == it.trackServiceId + }) { if (!isOnline()) { launchUI { _snackbarState.emit( SnackbarState( message = - "No network connection, cannot autolink tracker" - ) - ) + "No network connection, cannot autolink tracker")) } } else { val trackResult = @@ -973,30 +943,23 @@ class MangaDetailPresenter( .getService(trackService.id)!! .toTrackServiceItem(), currentManga(), - false - ) - - if ( - trackResult - is - TrackingConstants.TrackSearchResult.Success - ) { + false) + + if (trackResult + is + TrackingConstants.TrackSearchResult.Success) { val trackSearchItem = trackResult.trackSearchResult[0] val trackingUpdate = trackingCoordinator.registerTracking( TrackAndService( trackSearchItem.trackItem, - trackService - ), - mangaId - ) + trackService), + mangaId) handleTrackingUpdate(trackingUpdate, false) - } else if ( - trackResult - is - TrackingConstants.TrackSearchResult.Error - ) { + } else if (trackResult + is + TrackingConstants.TrackSearchResult.Error) { launchUI { _snackbarState.emit( SnackbarState( @@ -1076,19 +1039,13 @@ class MangaDetailPresenter( return when (sortOrder) { Manga.CHAPTER_SORTING_NUMBER -> MangaConstants.SortFilter( - chapterNumberSort = status, - matchesGlobalDefaults = matchesDefaults - ) + chapterNumberSort = status, matchesGlobalDefaults = matchesDefaults) Manga.CHAPTER_SORTING_UPLOAD_DATE -> MangaConstants.SortFilter( - uploadDateSort = status, - matchesGlobalDefaults = matchesDefaults - ) + uploadDateSort = status, matchesGlobalDefaults = matchesDefaults) else -> MangaConstants.SortFilter( - sourceOrderSort = status, - matchesGlobalDefaults = matchesDefaults - ) + sourceOrderSort = status, matchesGlobalDefaults = matchesDefaults) } } @@ -1134,8 +1091,7 @@ class MangaDetailPresenter( downloaded = downloaded, bookmarked = bookmark, hideChapterTitles = hideTitle, - matchesGlobalDefaults = matchesDefaults - ) + matchesGlobalDefaults = matchesDefaults) } /** Get scanlator filter */ @@ -1149,9 +1105,7 @@ class MangaDetailPresenter( ) .map { scanlator -> MangaConstants.ScanlatorOption( - name = scanlator, - disabled = filteredScanlators.contains(scanlator) - ) + name = scanlator, disabled = filteredScanlators.contains(scanlator)) } return MangaConstants.ScanlatorFilter(scanlators = scanlatorOptions.toImmutableList()) } @@ -1166,9 +1120,7 @@ class MangaDetailPresenter( ) .map { language -> MangaConstants.LanguageOption( - name = language, - disabled = filteredLanguages.contains(language) - ) + name = language, disabled = filteredLanguages.contains(language)) } return MangaConstants.LanguageFilter(languages = languageOptions.toImmutableList()) } @@ -1185,23 +1137,18 @@ class MangaDetailPresenter( val hasDisabledScanlators = chapterScanlatorFilter.scanlators.any { it.disabled } val filtersId = mutableListOf() filtersId.add( - if (chapterDisplay.unread == ToggleableState.Indeterminate) R.string.read else null - ) + if (chapterDisplay.unread == ToggleableState.Indeterminate) R.string.read else null) filtersId.add(if (chapterDisplay.unread == ToggleableState.On) R.string.unread else null) filtersId.add( - if (chapterDisplay.downloaded == ToggleableState.On) R.string.downloaded else null - ) + if (chapterDisplay.downloaded == ToggleableState.On) R.string.downloaded else null) filtersId.add( if (chapterDisplay.downloaded == ToggleableState.Indeterminate) R.string.not_downloaded - else null - ) + else null) filtersId.add( - if (chapterDisplay.bookmarked == ToggleableState.On) R.string.bookmarked else null - ) + if (chapterDisplay.bookmarked == ToggleableState.On) R.string.bookmarked else null) filtersId.add( if (chapterDisplay.bookmarked == ToggleableState.Indeterminate) R.string.not_bookmarked - else null - ) + else null) filtersId.add(if (hasDisabledScanlators) R.string.scanlators else null) return filtersId.filterNotNull().joinToString(", ") { preferences.context.getString(it) } } @@ -1241,14 +1188,12 @@ class MangaDetailPresenter( presenterScope.launchIO { val manga = currentManga() - if ( - !manga.usesLocalFilter && - manga.readFilter(mangaDetailsPreferences) == Manga.SHOW_ALL && - manga.downloadedFilter(mangaDetailsPreferences) == Manga.SHOW_ALL && - manga.bookmarkedFilter( - mangaDetailsPreferences, - ) == Manga.SHOW_ALL - ) { + if (!manga.usesLocalFilter && + manga.readFilter(mangaDetailsPreferences) == Manga.SHOW_ALL && + manga.downloadedFilter(mangaDetailsPreferences) == Manga.SHOW_ALL && + manga.bookmarkedFilter( + mangaDetailsPreferences, + ) == Manga.SHOW_ALL) { manga.readFilter = Manga.SHOW_ALL manga.bookmarkedFilter = Manga.SHOW_ALL manga.downloadedFilter = Manga.SHOW_ALL @@ -1431,8 +1376,7 @@ class MangaDetailPresenter( rating = m.rating, follows = m.users, threadId = m.thread_id, - repliesCount = m.replies_count - ), + repliesCount = m.replies_count), status = m.status, ) } @@ -1521,9 +1465,7 @@ class MangaDetailPresenter( downloadManager.deleteManga(currentManga()) } else { downloadManager.deleteChapters( - chapterItems.map { it.chapter.toDbChapter() }, - currentManga() - ) + chapterItems.map { it.chapter.toDbChapter() }, currentManga()) } } if (canUndo) { @@ -1580,15 +1522,13 @@ class MangaDetailPresenter( currentManga(), generalState.value.activeChapters .filter { !it.isDownloaded } - .map { it.chapter.toDbChapter() } - ) + .map { it.chapter.toDbChapter() }) } is DownloadAction.Download -> { addToLibrarySnack() downloadManager.downloadChapters( currentManga(), - chapterItems.filter { !it.isDownloaded }.map { it.chapter.toDbChapter() } - ) + chapterItems.filter { !it.isDownloaded }.map { it.chapter.toDbChapter() }) } is DownloadAction.DownloadNextUnread -> { val filteredChapters = @@ -1635,10 +1575,8 @@ class MangaDetailPresenter( ) { presenterScope.launchIO { val initialChapterItems = - if ( - markAction is MangaConstants.MarkAction.PreviousRead || - markAction is MangaConstants.MarkAction.PreviousUnread - ) { + if (markAction is MangaConstants.MarkAction.PreviousRead || + markAction is MangaConstants.MarkAction.PreviousUnread) { when (currentManga().sortDescending(mangaDetailsPreferences)) { true -> (markAction as? MangaConstants.MarkAction.PreviousRead)?.altChapters @@ -1681,8 +1619,7 @@ class MangaDetailPresenter( it.copy( read = false, lastPageRead = markAction.lastRead ?: 0, - pagesLeft = markAction.pagesLeft ?: 0 - ) + pagesLeft = markAction.pagesLeft ?: 0) } to R.string.marked_as_unread } } @@ -1698,8 +1635,7 @@ class MangaDetailPresenter( newChapterItems .filter { !it.bookmark } .map { ChapterItem(chapter = it) }, - newChapterItems.size == generalState.value.allChapters.size - ) + newChapterItems.size == generalState.value.allChapters.size) } // get the highest chapter number and update tracking for it newChapterItems @@ -1718,9 +1654,7 @@ class MangaDetailPresenter( presenterScope.launch { _snackbarState.emit( SnackbarState( - "Error trying to update tracked chapter marked as read ${it.message}" - ) - ) + "Error trying to update tracked chapter marked as read ${it.message}")) } } } @@ -1801,11 +1735,9 @@ class MangaDetailPresenter( false -> R.string.start_reading_ } val readTxt = - if ( - nextChapter.isMergedChapter() || - (nextChapter.volume.isEmpty() && - nextChapter.chapterText.isEmpty()) - ) { + if (nextChapter.isMergedChapter() || + (nextChapter.volume.isEmpty() && + nextChapter.chapterText.isEmpty())) { nextChapter.name } else if (nextChapter.volume.isNotEmpty()) { "Vol. " + nextChapter.volume + " " + nextChapter.chapterText @@ -1843,8 +1775,7 @@ class MangaDetailPresenter( when (!isOnline()) { true -> _snackbarState.emit( - SnackbarState(message = "No network connection, cannot open comments") - ) + SnackbarState(message = "No network connection, cannot open comments")) false -> { _isRefreshing.value = true val threadId = @@ -1906,8 +1837,7 @@ class MangaDetailPresenter( presenterScope.launchIO { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) { _snackbarState.emit( - SnackbarState(messageRes = R.string._copied_to_clipboard, message = message) - ) + SnackbarState(messageRes = R.string._copied_to_clipboard, message = message)) } } } @@ -1957,9 +1887,7 @@ class MangaDetailPresenter( val mutableChapters = currentChapters.toMutableList() val updateChapter = currentChapters[index].copy( - downloadState = download.status, - downloadProgress = download.progress - ) + downloadState = download.status, downloadProgress = download.progress) mutableChapters[index] = updateChapter _generalState.update { it.copy( diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaUpdateCoordinator.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaUpdateCoordinator.kt index 35f6317dcb..db8a633a41 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaUpdateCoordinator.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaUpdateCoordinator.kt @@ -101,18 +101,14 @@ class MangaUpdateCoordinator { manga.initialized = true // This clears custom titles from j2k/sy and if MangaDex removes the title manga.user_title?.let { customTitle -> - if ( - customTitle != manga.originalTitle && - customTitle !in manga.getAltTitles() - ) { + if (customTitle != manga.originalTitle && + customTitle !in manga.getAltTitles()) { manga.user_title = null } } - if ( - networkManga.thumbnail_url != null && - networkManga.thumbnail_url != originalThumbnail && - originalThumbnail != MdConstants.noCoverUrl - ) { + if (networkManga.thumbnail_url != null && + networkManga.thumbnail_url != originalThumbnail && + originalThumbnail != MdConstants.noCoverUrl) { coverCache.deleteFromCache(originalThumbnail, manga.favorite) } db.insertManga(manga).executeOnIO() @@ -165,9 +161,7 @@ class MangaUpdateCoordinator { send( MangaResult.Error( text = - "error with ${MergeType.getMergeTypeName(mergeManga.mergeType)}: ${it.message()}" - ) - ) + "error with ${MergeType.getMergeTypeName(mergeManga.mergeType)}: ${it.message()}")) this.cancel() } .getOrElse { emptyList() } @@ -189,8 +183,7 @@ class MangaUpdateCoordinator { manga, newChapters.first .mapNotNull { it.toSimpleChapter()?.toChapterItem() } - .sortedBy { it.chapter.chapterNumber } - ) + .sortedBy { it.chapter.chapterNumber }) } } mangaShortcutManager.updateShortcuts() diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/TrackingCoordinator.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/TrackingCoordinator.kt index 23452eabb2..62ec2dfd87 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/TrackingCoordinator.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/TrackingCoordinator.kt @@ -31,10 +31,8 @@ class TrackingCoordinator { var track = trackAndService.track.copy(status = trackAndService.service.statusList[statusIndex]) - if ( - trackManager.getService(trackAndService.service.id)!!.isCompletedStatus(statusIndex) && - track.totalChapters > 0 - ) { + if (trackManager.getService(trackAndService.service.id)!!.isCompletedStatus(statusIndex) && + track.totalChapters > 0) { track = track.copy(lastChapterRead = track.totalChapters.toFloat()) } return updateTrackingService(track, trackAndService.service) @@ -165,8 +163,7 @@ class TrackingCoordinator { true -> TrackingConstants.TrackSearchResult.NoResult false -> TrackingConstants.TrackSearchResult.Success( - results.map { it.toTrackSearchItem() }.toImmutableList() - ) + results.map { it.toTrackSearchItem() }.toImmutableList()) }, ) } @@ -174,10 +171,7 @@ class TrackingCoordinator { TimberKt.e(it) { "error searching tracker" } emit( TrackingConstants.TrackSearchResult.Error( - it.message ?: "Error searching tracker", - service.nameRes - ) - ) + it.message ?: "Error searching tracker", service.nameRes)) } /** Search Tracker */ @@ -195,16 +189,13 @@ class TrackingCoordinator { true -> TrackingConstants.TrackSearchResult.NoResult false -> TrackingConstants.TrackSearchResult.Success( - results.map { it.toTrackSearchItem() }.toImmutableList() - ) + results.map { it.toTrackSearchItem() }.toImmutableList()) } } .getOrElse { TimberKt.e(it) { "error searching tracker" } TrackingConstants.TrackSearchResult.Error( - it.message ?: "Error searching tracker", - service.nameRes - ) + it.message ?: "Error searching tracker", service.nameRes) } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/BaseChapterHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/BaseChapterHolder.kt index 1a48c453fd..20e930c7ac 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/BaseChapterHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/BaseChapterHolder.kt @@ -20,10 +20,8 @@ open class BaseChapterHolder( val chapter = adapter.getItem(flexibleAdapterPosition) as? BaseChapterItem<*, *> ?: return val downloadButton = itemView.findViewById(R.id.download_button) ?: return - if ( - chapter.status == Download.State.NOT_DOWNLOADED || - chapter.status == Download.State.ERROR - ) { + if (chapter.status == Download.State.NOT_DOWNLOADED || + chapter.status == Download.State.ERROR) { adapter.baseDelegate?.downloadChapter(flexibleAdapterPosition) } else { downloadButton.post { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/more/NewUpdateDialogController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/more/NewUpdateDialogController.kt index 94a1d858ec..e3f4cb4479 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/more/NewUpdateDialogController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/more/NewUpdateDialogController.kt @@ -10,8 +10,7 @@ import org.nekomanga.R @Deprecated( message = - "This is only used from the main screen when it auto checks. Manual checks use compose version remove when everything is composed" -) + "This is only used from the main screen when it auto checks. Manual checks use compose version remove when everything is composed") class NewUpdateDialogController(bundle: Bundle? = null) : DialogController(bundle) { constructor( diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/more/about/AboutPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/more/about/AboutPresenter.kt index 6ed1b8a346..7d7db6dfc6 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/more/about/AboutPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/more/about/AboutPresenter.kt @@ -62,8 +62,7 @@ class AboutPresenter : BaseCoroutinePresenter() { } is AppUpdateResult.NoNewUpdate -> { _snackbarState.emit( - SnackbarState(messageRes = R.string.no_new_updates_available) - ) + SnackbarState(messageRes = R.string.no_new_updates_available)) } is AppUpdateResult.NewUpdate -> { _aboutScreenState.update { @@ -87,9 +86,7 @@ class AboutPresenter : BaseCoroutinePresenter() { _snackbarState.emit( SnackbarState( messageRes = R.string._copied_to_clipboard, - fieldRes = R.string.build_information - ) - ) + fieldRes = R.string.build_information)) } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/more/stats/StatsPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/more/stats/StatsPresenter.kt index 83c514b663..fb0dcd687d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/more/stats/StatsPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/more/stats/StatsPresenter.kt @@ -142,8 +142,8 @@ class StatsPresenter( .map { category -> category.name } .takeUnless { it.isEmpty() } ?: listOf( - prefs.context.getString(R.string.default_value) - )) + prefs.context.getString( + R.string.default_value))) .sorted() .toImmutableList(), ) @@ -190,8 +190,7 @@ class StatsPresenter( StatsConstants.DetailedTagState( totalReadDuration = totalDuration, totalChapters = totalCount, - sortedTagPairs = sortedSeries - ), + sortedTagPairs = sortedSeries), ) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/onboarding/OnboardingController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/onboarding/OnboardingController.kt index 31e392b83c..49068f24c1 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/onboarding/OnboardingController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/onboarding/OnboardingController.kt @@ -53,8 +53,7 @@ class OnboardingController : BasicComposeController() { if (currentStep > 0) { currentStep-- } - } - ) + }) InfoScreen( headingText = stringResource(R.string.onboarding_heading), @@ -76,28 +75,27 @@ class OnboardingController : BasicComposeController() { } false -> currentStep++ } - } - ) { - Box( - modifier = - Modifier.padding(vertical = Size.small) - .clip(MaterialTheme.shapes.small) - .fillMaxSize() - .background(MaterialTheme.colorScheme.surfaceVariant), - ) { - AnimatedContent( - targetState = currentStep, - transitionSpec = { - materialSharedAxisX( - forward = targetState > initialState, - slideDistance = slideDistance, - ) - }, - label = "stepContent", - ) { step -> - steps[step].Content() + }) { + Box( + modifier = + Modifier.padding(vertical = Size.small) + .clip(MaterialTheme.shapes.small) + .fillMaxSize() + .background(MaterialTheme.colorScheme.surfaceVariant), + ) { + AnimatedContent( + targetState = currentStep, + transitionSpec = { + materialSharedAxisX( + forward = targetState > initialState, + slideDistance = slideDistance, + ) + }, + label = "stepContent", + ) { step -> + steps[step].Content() + } } } - } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt index 96e3a1a2cd..786e766265 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt @@ -568,11 +568,9 @@ class ReaderActivity : BaseActivity() { } override fun finishAfterTransition() { - if ( - didTransistionFromChapter && - visibleChapterRange.isNotEmpty() && - MainActivity.chapterIdToExitTo !in visibleChapterRange - ) { + if (didTransistionFromChapter && + visibleChapterRange.isNotEmpty() && + MainActivity.chapterIdToExitTo !in visibleChapterRange) { finish() } else { viewModel.onBackPressed() @@ -772,20 +770,16 @@ class ReaderActivity : BaseActivity() { if (event?.action == MotionEvent.ACTION_UP) { if (!result) { val sheetBehavior = binding.chaptersSheet.root.sheetBehavior - if ( - sheetBehavior?.state != BottomSheetBehavior.STATE_SETTLING && - !sheetBehavior.isCollapsed() - ) { + if (sheetBehavior?.state != BottomSheetBehavior.STATE_SETTLING && + !sheetBehavior.isCollapsed()) { sheetBehavior?.collapse() } } if (readerNavGestureDetector.lockVertical) { return@setOnTouchListener true } - } else if ( - (event?.action != MotionEvent.ACTION_UP || - event.action != MotionEvent.ACTION_DOWN) && result - ) { + } else if ((event?.action != MotionEvent.ACTION_UP || + event.action != MotionEvent.ACTION_DOWN) && result) { event.action = MotionEvent.ACTION_CANCEL return@setOnTouchListener false } @@ -804,13 +798,10 @@ class ReaderActivity : BaseActivity() { val prevValue = (viewer as? PagerViewer)?.pager?.currentItem ?: -1 moveToPageIndex(value.roundToInt()) val newValue = (viewer as? PagerViewer)?.pager?.currentItem ?: -1 - if ( - Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1 && - ((prevValue > -1 && newValue != prevValue) || viewer !is PagerViewer) - ) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1 && + ((prevValue > -1 && newValue != prevValue) || viewer !is PagerViewer)) { binding.readerNav.pageSeekbar.performHapticFeedback( - HapticFeedbackConstants.TEXT_HANDLE_MOVE - ) + HapticFeedbackConstants.TEXT_HANDLE_MOVE) } } } @@ -822,9 +813,8 @@ class ReaderActivity : BaseActivity() { if (it.hasExtraPage(value.roundToInt(), viewModel.getCurrentChapter())) { val invertDoublePage = (viewer as? PagerViewer)?.config?.invertDoublePages ?: false - return@setLabelFormatter if ( - !binding.readerNav.pageSeekbar.isRTL.xor(invertDoublePage) - ) { + return@setLabelFormatter if (!binding.readerNav.pageSeekbar.isRTL.xor( + invertDoublePage)) { "$pageNumber-${pageNumber + 1}" } else { "${pageNumber + 1}-$pageNumber" @@ -868,8 +858,7 @@ class ReaderActivity : BaseActivity() { topMargin = systemInsets.top } binding.chaptersSheet.chaptersBottomSheet.updateLayoutParams< - ViewGroup.MarginLayoutParams - > { + ViewGroup.MarginLayoutParams> { leftMargin = systemInsets.left rightMargin = systemInsets.right height = 280.dpToPx + systemInsets.bottom @@ -891,8 +880,7 @@ class ReaderActivity : BaseActivity() { ) } binding.chaptersSheet.chapterRecycler.updatePaddingRelative( - bottom = systemInsets.bottom - ) + bottom = systemInsets.bottom) binding.viewerContainer.requestLayout() } if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) { @@ -1044,10 +1032,8 @@ class ReaderActivity : BaseActivity() { if (binding.chaptersSheet.chaptersBottomSheet.sheetBehavior.isExpanded()) { binding.chaptersSheet.chaptersBottomSheet.sheetBehavior?.isHideable = false } - if ( - !binding.chaptersSheet.chaptersBottomSheet.sheetBehavior.isExpanded() && - sheetManageNavColor - ) { + if (!binding.chaptersSheet.chaptersBottomSheet.sheetBehavior.isExpanded() && + sheetManageNavColor) { window.navigationBarColor = Color.TRANSPARENT } if (animate && oldVisibility != menuVisible) { @@ -1055,8 +1041,7 @@ class ReaderActivity : BaseActivity() { val toolbarAnimation = AnimationUtils.loadAnimation(this, R.anim.enter_from_top) toolbarAnimation.doOnStart { window.addFlags( - WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS - ) + WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) } binding.appBar.startAnimation(toolbarAnimation) } @@ -1101,11 +1086,9 @@ class ReaderActivity : BaseActivity() { else -> R2LPagerViewer(this) } - if ( - noDefault && - viewModel.manga?.readingModeType!! > 0 && - viewModel.manga?.readingModeType!! != readerPreferences.defaultReadingMode().get() - ) { + if (noDefault && + viewModel.manga?.readingModeType!! > 0 && + viewModel.manga?.readingModeType!! != readerPreferences.defaultReadingMode().get()) { snackbar = binding.readerLayout.snack( getString( @@ -1256,8 +1239,7 @@ class ReaderActivity : BaseActivity() { if (viewModel.manga!!.hideChapterTitle(mangaDetailsPreferences)) { val number = decimalFormat.format( - viewerChapters.currChapter.chapter.chapter_number.toDouble() - ) + viewerChapters.currChapter.chapter.chapter_number.toDouble()) getString(R.string.chapter_, number) } else { viewerChapters.currChapter.chapter.name @@ -1365,9 +1347,8 @@ class ReaderActivity : BaseActivity() { binding.readerNav.leftPageText.text = currentPage binding.readerNav.rightPageText.text = totalPages } - if ( - binding.chaptersSheet.chaptersBottomSheet.selectedChapterId != page.chapter.chapter.id - ) { + if (binding.chaptersSheet.chaptersBottomSheet.selectedChapterId != + page.chapter.chapter.id) { binding.chaptersSheet.chaptersBottomSheet.refreshList() } // Set seekbar progress @@ -1461,10 +1442,8 @@ class ReaderActivity : BaseActivity() { val isLTR = (viewer !is R2LPagerViewer).xor(viewer.config.invertDoublePages) val bg = - if ( - viewer.config.readerTheme >= 2 || - viewer.config.readerTheme == 0 - ) { + if (viewer.config.readerTheme >= 2 || + viewer.config.readerTheme == 0) { Color.WHITE } else { Color.BLACK @@ -1654,8 +1633,7 @@ class ReaderActivity : BaseActivity() { if (errors.size > 1) { getString( R.string.failed_to_update_, - errors.joinToString(", ") { getString(it.first.nameRes()) } - ) + errors.joinToString(", ") { getString(it.first.nameRes()) }) } else { val (service, errorMessage) = errors.first() buildSpannedString { @@ -1665,8 +1643,7 @@ class ReaderActivity : BaseActivity() { val size = resources.getDimension( com.google.android.material.R.dimen - .design_snackbar_text_size - ) + .design_snackbar_text_size) val dRatio = intrinsicWidth / intrinsicHeight.toFloat() setBounds(0, 0, (size * dRatio).roundToInt(), size.roundToInt()) } ?: return @@ -1828,8 +1805,7 @@ class ReaderActivity : BaseActivity() { merge( readerPreferences.grayscale().changes(), - readerPreferences.invertedColors().changes() - ) + readerPreferences.invertedColors().changes()) .onEach { setLayerPaint( readerPreferences.grayscale().get(), @@ -1857,8 +1833,7 @@ class ReaderActivity : BaseActivity() { .onEach { val isPaused = !this@ReaderActivity.lifecycle.currentState.isAtLeast( - Lifecycle.State.RESUMED - ) + Lifecycle.State.RESUMED) if (isPaused) { (viewer as? PagerViewer)?.config?.let { config -> reloadChapters(config.doublePages, true) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderNavGestureDetector.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderNavGestureDetector.kt index f5ba82990e..edd041b31d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderNavGestureDetector.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderNavGestureDetector.kt @@ -49,12 +49,10 @@ class ReaderNavGestureDetector(private val activity: ReaderActivity) : val diffY = e2.y - startingY val diffX = e2.x - startingX val sheetBehavior = activity.binding.chaptersSheet.root.sheetBehavior - if ( - !hasScrollHorizontal && - abs(diffX) < abs(diffY) && - (abs(diffY) > SWIPE_THRESHOLD || abs(velocityY) > SWIPE_VELOCITY_THRESHOLD) && - diffY <= 0 - ) { + if (!hasScrollHorizontal && + abs(diffX) < abs(diffY) && + (abs(diffY) > SWIPE_THRESHOLD || abs(velocityY) > SWIPE_VELOCITY_THRESHOLD) && + diffY <= 0) { lockVertical = true sheetBehavior?.expand() result = true diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderViewModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderViewModel.kt index ba2bd1a005..fea9e1a229 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderViewModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderViewModel.kt @@ -234,12 +234,7 @@ class ReaderViewModel( val context = Injekt.get() loader = ChapterLoader( - context, - downloadManager, - downloadProvider, - manga, - sourceManager - ) + context, downloadManager, downloadProvider, manga, sourceManager) loadChapter(loader!!, chapterList.first { chapterId == it.chapter.id }) Result.success(true) @@ -420,9 +415,8 @@ class ReaderViewModel( } } - if ( - chapter.state != ReaderChapter.State.Wait && chapter.state !is ReaderChapter.State.Error - ) { + if (chapter.state != ReaderChapter.State.Wait && + chapter.state !is ReaderChapter.State.Error) { return } @@ -467,12 +461,10 @@ class ReaderViewModel( !securityPreferences.incognitoMode().get() || hasTrackers || preferences.readingSync().get() - if ( - shouldTrack && - // For double pages, check if the second to last page is doubled up - ((selectedChapter.pages?.lastIndex == page.index && page.firstHalf != true) || - (hasExtraPage && selectedChapter.pages?.lastIndex?.minus(1) == page.index)) - ) { + if (shouldTrack && + // For double pages, check if the second to last page is doubled up + ((selectedChapter.pages?.lastIndex == page.index && page.firstHalf != true) || + (hasExtraPage && selectedChapter.pages?.lastIndex?.minus(1) == page.index))) { if (!securityPreferences.incognitoMode().get()) { selectedChapter.chapter.read = true updateTrackChapterAfterReading(selectedChapter) @@ -534,9 +526,7 @@ class ReaderViewModel( */ private fun downloadChapters(chapters: List) { downloadManager.downloadChapters( - manga!!, - chapters.filter { !it.isDownloaded }.map { it.chapter.toDbChapter() } - ) + manga!!, chapters.filter { !it.isDownloaded }.map { it.chapter.toDbChapter() }) } /** @@ -567,11 +557,9 @@ class ReaderViewModel( chapterToDownload = null } // Check if deleting option is enabled and chapter exists - if ( - removeAfterReadSlots != -1 && - chapterToDelete != null && - !currentChapter.chapter.bookmark - ) { + if (removeAfterReadSlots != -1 && + chapterToDelete != null && + !currentChapter.chapter.bookmark) { enqueueDeleteReadChapters(chapterToDelete) } } @@ -968,9 +956,7 @@ class ReaderViewModel( if (!preferences.readingSync().get() && !readerChapter.chapter.isMergedChapter()) return scope.launchIO { statusHandler.marksChaptersStatus( - manga!!.uuid(), - listOf(readerChapter.chapter.mangadex_chapter_id) - ) + manga!!.uuid(), listOf(readerChapter.chapter.mangadex_chapter_id)) } } @@ -990,8 +976,7 @@ class ReaderViewModel( launchIO { eventChannel.send(Event.ShareTrackingError(listOf(service to message))) } - } - ) + }) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/SaveImageNotifier.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/SaveImageNotifier.kt index ea59a5208c..c81033b576 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/SaveImageNotifier.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/SaveImageNotifier.kt @@ -70,20 +70,14 @@ class SaveImageNotifier(private val context: Context) { R.drawable.ic_share_24dp, context.getString(R.string.share), NotificationReceiver.shareImagePendingBroadcast( - context, - file.uri.path ?: "", - notificationId - ), + context, file.uri.path ?: "", notificationId), ) // Delete action addAction( R.drawable.ic_delete_24dp, context.getString(R.string.delete), NotificationReceiver.deleteImagePendingBroadcast( - context, - file.uri.path ?: "", - notificationId - ), + context, file.uri.path ?: "", notificationId), ) updateNotification() diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/chapter/ReaderChapterItem.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/chapter/ReaderChapterItem.kt index 8037816997..4a64403640 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/chapter/ReaderChapterItem.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/chapter/ReaderChapterItem.kt @@ -78,13 +78,11 @@ class ReaderChapterItem(val chapter: Chapter, val manga: Manga, val isCurrent: B binding.chapterSubtitle.setTypeface(null, Typeface.NORMAL) } - if ( - item.chapter.language.isNullOrBlank() || - item.chapter.language.equals( - "english", - true, - ) - ) { + if (item.chapter.language.isNullOrBlank() || + item.chapter.language.equals( + "english", + true, + )) { binding.chapterLanguage.isVisible = false } else { binding.chapterLanguage.isVisible = true diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/chapter/ReaderChapterSheet.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/chapter/ReaderChapterSheet.kt index 9f113b1e74..3bcc419e4c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/chapter/ReaderChapterSheet.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/chapter/ReaderChapterSheet.kt @@ -102,12 +102,9 @@ class ReaderChapterSheet @JvmOverloads constructor(context: Context, attrs: Attr activity.window.navigationBarColor = lerpColor( ColorUtils.setAlphaComponent( - navPrimary, - if (hasLightNav) 0 else 179 - ), + navPrimary, if (hasLightNav) 0 else 179), navPrimary, - trueProgress - ) + trueProgress) } } @@ -118,8 +115,7 @@ class ReaderChapterSheet @JvmOverloads constructor(context: Context, attrs: Attr (binding.chapterRecycler.layoutManager as LinearLayoutManager) .scrollToPositionWithOffset( adapter?.getPosition( - viewModel.getCurrentChapter()?.chapter?.id ?: 0L - ) ?: 0, + viewModel.getCurrentChapter()?.chapter?.id ?: 0L) ?: 0, binding.chapterRecycler.height / 2 - 30.dpToPx, ) if (canShowNav) { @@ -127,10 +123,8 @@ class ReaderChapterSheet @JvmOverloads constructor(context: Context, attrs: Attr } activity.binding.readerNav.root.alpha = 1f } - if ( - state == BottomSheetBehavior.STATE_DRAGGING || - state == BottomSheetBehavior.STATE_SETTLING - ) { + if (state == BottomSheetBehavior.STATE_DRAGGING || + state == BottomSheetBehavior.STATE_SETTLING) { if (canShowNav) { activity.binding.readerNav.root.isVisible = true } @@ -222,10 +216,8 @@ class ReaderChapterSheet @JvmOverloads constructor(context: Context, attrs: Attr object : RecyclerView.OnScrollListener() { override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) { super.onScrollStateChanged(recyclerView, newState) - if ( - newState == RecyclerView.SCROLL_STATE_IDLE || - newState == RecyclerView.SCROLL_STATE_SETTLING - ) { + if (newState == RecyclerView.SCROLL_STATE_IDLE || + newState == RecyclerView.SCROLL_STATE_SETTLING) { sheetBehavior?.isDraggable = true } else { sheetBehavior?.isDraggable = !recyclerView.canScrollVertically(-1) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/HttpPageLoader.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/HttpPageLoader.kt index 5b5afffd9e..30c78706e4 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/HttpPageLoader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/HttpPageLoader.kt @@ -102,11 +102,9 @@ class HttpPageLoader( val imageUrl = page.imageUrl // Check if the image has been deleted - if ( - page.status == Page.State.READY && - imageUrl != null && - !chapterCache.isImageInCache(imageUrl) - ) { + if (page.status == Page.State.READY && + imageUrl != null && + !chapterCache.isImageInCache(imageUrl)) { page.status = Page.State.QUEUE } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/settings/OrientationType.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/settings/OrientationType.kt index b92fd35ea9..0e7511962b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/settings/OrientationType.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/settings/OrientationType.kt @@ -15,38 +15,32 @@ enum class OrientationType( 0, ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED, R.string.default_value, - R.drawable.ic_screen_rotation_24dp - ), + R.drawable.ic_screen_rotation_24dp), FREE( 1, ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED, R.string.free, - R.drawable.ic_screen_rotation_24dp - ), + R.drawable.ic_screen_rotation_24dp), PORTRAIT( 2, ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT, R.string.portrait, - R.drawable.ic_stay_current_portrait_24dp - ), + R.drawable.ic_stay_current_portrait_24dp), LANDSCAPE( 3, ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE, R.string.landscape, - R.drawable.ic_stay_current_landscape_24dp - ), + R.drawable.ic_stay_current_landscape_24dp), LOCKED_PORTRAIT( 4, ActivityInfo.SCREEN_ORIENTATION_PORTRAIT, R.string.locked_portrait, - R.drawable.ic_screen_lock_portrait_24dp - ), + R.drawable.ic_screen_lock_portrait_24dp), LOCKED_LANDSCAPE( 5, ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE, R.string.locked_landscape, - R.drawable.ic_screen_lock_landscape_24dp - ), + R.drawable.ic_screen_lock_landscape_24dp), ; @Suppress("RemoveRedundantQualifierName") val flagValue = prefValue shl OrientationType.SHIFT diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/settings/ReaderFilterView.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/settings/ReaderFilterView.kt index e96f215141..f02167701c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/settings/ReaderFilterView.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/settings/ReaderFilterView.kt @@ -180,8 +180,7 @@ class ReaderFilterView @JvmOverloads constructor(context: Context, attrs: Attrib fun setWindowBrightness() { setCustomBrightnessValue( readerPreferences.customBrightnessValue().get(), - !readerPreferences.customBrightness().get() - ) + !readerPreferences.customBrightness().get()) } /** diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/settings/ReaderGeneralView.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/settings/ReaderGeneralView.kt index c41634e4af..0c0663f354 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/settings/ReaderGeneralView.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/settings/ReaderGeneralView.kt @@ -20,10 +20,8 @@ class ReaderGeneralView @JvmOverloads constructor(context: Context, attrs: Attri (context as ReaderActivity).viewModel.setMangaReadingMode(readingModeType.flagValue) val mangaViewer = activity.viewModel.getMangaReadingMode() - if ( - mangaViewer == ReadingModeType.WEBTOON.flagValue || - mangaViewer == ReadingModeType.CONTINUOUS_VERTICAL.flagValue - ) { + if (mangaViewer == ReadingModeType.WEBTOON.flagValue || + mangaViewer == ReadingModeType.CONTINUOUS_VERTICAL.flagValue) { initWebtoonPreferences() } else { initPagerPreferences() @@ -49,8 +47,7 @@ class ReaderGeneralView @JvmOverloads constructor(context: Context, attrs: Attri binding.fullscreen.bindToPreference(readerPreferences.fullscreen()) binding.keepscreen.bindToPreference(readerPreferences.keepScreenOn()) binding.alwaysShowChapterTransition.bindToPreference( - readerPreferences.alwaysShowChapterTransition() - ) + readerPreferences.alwaysShowChapterTransition()) } /** Init the preferences for the webtoon reader. */ diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/settings/ReaderPagedView.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/settings/ReaderPagedView.kt index 0c40d0456d..9ba397ed93 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/settings/ReaderPagedView.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/settings/ReaderPagedView.kt @@ -29,9 +29,7 @@ class ReaderPagedView @JvmOverloads constructor(context: Context, attrs: Attribu } doublePageGap.bindToIntPreference( - readerPreferences.doublePageGap(), - R.array.double_page_gap - ) + readerPreferences.doublePageGap(), R.array.double_page_gap) binding.navigatePan.bindToPreference(readerPreferences.navigateToPan()) binding.landscapeZoom.bindToPreference(readerPreferences.landscapeZoom()) zoomStart.bindToPreference(readerPreferences.zoomStart(), 1) @@ -57,8 +55,7 @@ class ReaderPagedView @JvmOverloads constructor(context: Context, attrs: Attribu } } doublePageRotateToFitInvert.bindToPreference( - readerPreferences.doublePageRotateReverse() - ) + readerPreferences.doublePageRotateReverse()) pageLayout.title = pageLayout.title.toString().addBetaTag(context, R.attr.colorSecondary) @@ -68,8 +65,7 @@ class ReaderPagedView @JvmOverloads constructor(context: Context, attrs: Attribu val hasMargins = mangaViewer == ReadingModeType.CONTINUOUS_VERTICAL.flagValue cropBordersWebtoon.bindToPreference( if (hasMargins) readerPreferences.cropBorders() - else readerPreferences.cropBordersWebtoon() - ) + else readerPreferences.cropBordersWebtoon()) webtoonSidePadding.bindToIntPreference( readerPreferences.webtoonSidePadding(), R.array.webtoon_side_padding_values, @@ -80,8 +76,7 @@ class ReaderPagedView @JvmOverloads constructor(context: Context, attrs: Attribu webtoonPageLayout.bindToPreference(readerPreferences.webtoonPageLayout()) webtoonInvertDoublePages.bindToPreference(readerPreferences.webtoonInvertDoublePages()) webtoonPageTransitions.bindToPreference( - readerPreferences.animatedPageTransitionsWebtoon() - ) + readerPreferences.animatedPageTransitionsWebtoon()) updatePagedGroup(!isWebtoonView) } @@ -93,8 +88,7 @@ class ReaderPagedView @JvmOverloads constructor(context: Context, attrs: Attribu val hasMargins = mangaViewer == ReadingModeType.CONTINUOUS_VERTICAL.flagValue binding.cropBordersWebtoon.bindToPreference( if (hasMargins) readerPreferences.cropBorders() - else readerPreferences.cropBordersWebtoon() - ) + else readerPreferences.cropBordersWebtoon()) updatePagedGroup(!isWebtoonView) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/settings/ReadingModeType.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/settings/ReadingModeType.kt index 461a949f37..421eb0fcd1 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/settings/ReadingModeType.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/settings/ReadingModeType.kt @@ -16,10 +16,7 @@ enum class ReadingModeType( VERTICAL(3, R.string.vertical_viewer, R.drawable.ic_reader_vertical_24dp), WEBTOON(4, R.string.webtoon, R.drawable.ic_reader_webtoon_24dp), CONTINUOUS_VERTICAL( - 5, - R.string.continuous_vertical, - R.drawable.ic_reader_continuous_vertical_24dp - ), + 5, R.string.continuous_vertical, R.drawable.ic_reader_continuous_vertical_24dp), ; @Suppress("RemoveRedundantQualifierName") val flagValue = prefValue shl ReadingModeType.SHIFT diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ReaderPageImageView.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ReaderPageImageView.kt index 0ecb817376..587d18bbc1 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ReaderPageImageView.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ReaderPageImageView.kt @@ -167,11 +167,9 @@ constructor( val insetInfo = config.insetInfo ?: return val topInsets = insetInfo.topCutoutInset val bottomInsets = insetInfo.bottomCutoutInset - if ( - insetInfo.cutoutBehavior == PagerConfig.CUTOUT_START_EXTENDED && - topInsets + bottomInsets > 0 && - insetInfo.scaleTypeIsFullFit - ) { + if (insetInfo.cutoutBehavior == PagerConfig.CUTOUT_START_EXTENDED && + topInsets + bottomInsets > 0 && + insetInfo.scaleTypeIsFullFit) { setScaleAndCenter( scale, PointF(centerV, (center?.y?.plus(topInsets)?.minus(bottomInsets) ?: 0f)), @@ -196,12 +194,10 @@ constructor( config.insetInfo.scaleTypeIsFullFit && topInsets + bottomInsets > 0, ) - if ( - (config.insetInfo.cutoutBehavior != PagerConfig.CUTOUT_IGNORE || - !config.insetInfo.scaleTypeIsFullFit) && - android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.Q && - config.insetInfo.isFullscreen - ) { + if ((config.insetInfo.cutoutBehavior != PagerConfig.CUTOUT_IGNORE || + !config.insetInfo.scaleTypeIsFullFit) && + android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.Q && + config.insetInfo.isFullscreen) { val insets: WindowInsets? = config.insetInfo.insets setExtraSpace( 0f, @@ -234,8 +230,7 @@ constructor( is InputStream -> setImage(ImageSource.inputStream(image)) else -> throw IllegalArgumentException( - "Not implemented for class ${image::class.simpleName}" - ) + "Not implemented for class ${image::class.simpleName}") } isVisible = true } @@ -296,8 +291,7 @@ constructor( is InputStream -> ByteBuffer.wrap(image.readBytes()) else -> throw IllegalArgumentException( - "Not implemented for class ${image::class.simpleName}" - ) + "Not implemented for class ${image::class.simpleName}") } val request = ImageRequest.Builder(context) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ReaderTransitionView.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ReaderTransitionView.kt index 9df66433ee..670e652df4 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ReaderTransitionView.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ReaderTransitionView.kt @@ -153,8 +153,7 @@ constructor(context: Context, attrs: AttributeSet? = null) : LinearLayout(contex resources.getQuantityString( R.plurals.missing_chapters_warning, chapterDifference.toInt(), - chapterDifference.toInt() - ) + chapterDifference.toInt()) binding.warning.isVisible = true } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerPageHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerPageHolder.kt index 497625d590..c56d4fb9a1 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerPageHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerPageHolder.kt @@ -130,11 +130,9 @@ class PagerPageHolder( override fun onImageLoaded() { super.onImageLoaded() (pageView as? SubsamplingScaleImageView)?.apply { - if ( - this@PagerPageHolder.extraPage == null && - this@PagerPageHolder.page.longPage == null && - sHeight < sWidth - ) { + if (this@PagerPageHolder.extraPage == null && + this@PagerPageHolder.page.longPage == null && + sHeight < sWidth) { this@PagerPageHolder.page.longPage = true } } @@ -201,8 +199,7 @@ class PagerPageHolder( progressBar.setProgress(progress) } else { progressBar.setProgress( - ((progress + extraProgress) / 2 * 0.95f).roundToInt() - ) + ((progress + extraProgress) / 2 * 0.95f).roundToInt()) } } } @@ -293,13 +290,10 @@ class PagerPageHolder( private fun SubsamplingScaleImageView.landscapeZoom(forward: Boolean?) { forward ?: return - if ( - viewer.config.landscapeZoom && - viewer.config.imageScaleType == - SubsamplingScaleImageView.SCALE_TYPE_CENTER_INSIDE && - sWidth > sHeight && - scale == minScale - ) { + if (viewer.config.landscapeZoom && + viewer.config.imageScaleType == SubsamplingScaleImageView.SCALE_TYPE_CENTER_INSIDE && + sWidth > sHeight && + scale == minScale) { handler.postDelayed( { val point = @@ -463,11 +457,9 @@ class PagerPageHolder( val stream2 = streamFn2?.invoke()?.buffered(16) openStream = - when ( - viewer.config.doublePageRotate && - stream2 == null && - ImageUtil.isWideImage(stream) - ) { + when (viewer.config.doublePageRotate && + stream2 == null && + ImageUtil.isWideImage(stream)) { true -> { val rotation = if (viewer.config.doublePageRotateReverse) -90f else 90f @@ -484,12 +476,10 @@ class PagerPageHolder( .doOnNext { isAnimated -> if (!isAnimated) { if (viewer.config.readerTheme >= 2) { - if ( - page.bg != null && - page.bgType == - getBGType(viewer.config.readerTheme, context) + - item.hashCode() - ) { + if (page.bg != null && + page.bgType == + getBGType(viewer.config.readerTheme, context) + + item.hashCode()) { setImage(openStream!!, false, imageConfig) pageView?.background = page.bg } @@ -843,20 +833,15 @@ class PagerPageHolder( imageStream.close() imageStream2.close() return ImageUtil.mergeBitmaps( - imageBitmap, - imageBitmap2, - isLTR, - bg, - viewer.config.doublePageGap - ) { - scope.launchUI { - if (it == 100) { - progressBar.completeAndFadeOut() - } else { - progressBar.setProgress(it) + imageBitmap, imageBitmap2, isLTR, bg, viewer.config.doublePageGap) { + scope.launchUI { + if (it == 100) { + progressBar.completeAndFadeOut() + } else { + progressBar.setProgress(it) + } } } - } } private fun splitDoublePages() { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerTransitionHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerTransitionHolder.kt index 4d25e239dc..da1bab7381 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerTransitionHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerTransitionHolder.kt @@ -53,10 +53,7 @@ class PagerTransitionHolder( addView(pagesContainer) transitionView.bind( - transition, - viewer.downloadManager, - viewer.activity.viewModel.state.value.manga - ) + transition, viewer.downloadManager, viewer.activity.viewModel.state.value.manga) transition.to?.let { observeStatus(it) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerViewer.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerViewer.kt index 83d2b51771..59e54fe43a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerViewer.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerViewer.kt @@ -86,9 +86,8 @@ abstract class PagerViewer(val activity: ReaderActivity) : BaseViewer { override fun onPageSelected(position: Int) { if (pager.isRestoring) return val page = adapter.joinedItems.getOrNull(position) - if ( - !activity.isScrollingThroughPagesOrChapters && page?.first !is ChapterTransition - ) { + if (!activity.isScrollingThroughPagesOrChapters && + page?.first !is ChapterTransition) { activity.hideMenu() } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerViewerAdapter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerViewerAdapter.kt index 6c8539b17d..f692a9fe7b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerViewerAdapter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerViewerAdapter.kt @@ -61,17 +61,14 @@ class PagerViewerAdapter(private val viewer: PagerViewer) : ViewPagerAdapter() { (chapters.prevChapter.pages?.count { it.fullPage == true || it.isolatedPage } ?: 0) if (prevPages != null) { newItems.addAll( - prevPages.takeLast(if ((prevPages.size + numberOfFullPages) % 2 == 0) 2 else 3) - ) + prevPages.takeLast(if ((prevPages.size + numberOfFullPages) % 2 == 0) 2 else 3)) } } // Skip transition page if the chapter is loaded & current page is not a transition page - if ( - prevHasMissingChapters || - forceTransition || - chapters.prevChapter?.state !is ReaderChapter.State.Loaded - ) { + if (prevHasMissingChapters || + forceTransition || + chapters.prevChapter?.state !is ReaderChapter.State.Loaded) { newItems.add(ChapterTransition.Prev(chapters.currChapter, chapters.prevChapter)) } @@ -86,11 +83,9 @@ class PagerViewerAdapter(private val viewer: PagerViewer) : ViewPagerAdapter() { // Add next chapter transition and pages. nextTransition = ChapterTransition.Next(chapters.currChapter, chapters.nextChapter).also { - if ( - nextHasMissingChapters || - forceTransition || - chapters.nextChapter?.state !is ReaderChapter.State.Loaded - ) { + if (nextHasMissingChapters || + forceTransition || + chapters.nextChapter?.state !is ReaderChapter.State.Loaded) { newItems.add(it) } } @@ -107,10 +102,8 @@ class PagerViewerAdapter(private val viewer: PagerViewer) : ViewPagerAdapter() { subItems = newItems.toMutableList() var useSecondPage = false - if ( - shifted != viewer.config.shiftDoublePage || - (doubledUp != viewer.config.doublePages && doubledUp) - ) { + if (shifted != viewer.config.shiftDoublePage || + (doubledUp != viewer.config.doublePages && doubledUp)) { if (shifted && (doubledUp == viewer.config.doublePages)) { useSecondPage = true } @@ -144,8 +137,8 @@ class PagerViewerAdapter(private val viewer: PagerViewer) : ViewPagerAdapter() { if (it.first is InsertPage && view.item is Pair<*, *>) { ((view.item as? Pair<*, *>?)?.first as? InsertPage)?.let { viewPage -> return@indexOfFirst (it.first as? InsertPage)?.isFromSamePage( - viewPage - ) == true && (it.first as? InsertPage)?.firstHalf == viewPage.firstHalf + viewPage) == true && + (it.first as? InsertPage)?.firstHalf == viewPage.firstHalf } } val secondPage = it.second as? ReaderPage @@ -238,10 +231,8 @@ class PagerViewerAdapter(private val viewer: PagerViewer) : ViewPagerAdapter() { // Step 1: segment the pages and transition pages subItems.forEach { if (it is ReaderPage) { - if ( - pagedItems.last().lastOrNull() != null && - pagedItems.last().last()?.chapter?.chapter?.id != it.chapter.chapter.id - ) { + if (pagedItems.last().lastOrNull() != null && + pagedItems.last().last()?.chapter?.chapter?.id != it.chapter.chapter.id) { pagedItems.add(mutableListOf()) } pagedItems.last().add(it) @@ -291,18 +282,15 @@ class PagerViewerAdapter(private val viewer: PagerViewer) : ViewPagerAdapter() { var itemIndex = 0 while (itemIndex < items.size) { items[itemIndex]?.isolatedPage = false - if ( - items[itemIndex]?.fullPage == true || items[itemIndex]?.shiftedPage == true - ) { + if (items[itemIndex]?.fullPage == true || + items[itemIndex]?.shiftedPage == true) { // Add a 'blank' page after each full page. It will be used when chunked to // solo a page items.add(itemIndex + 1, null) - if ( - items[itemIndex]?.fullPage == true && - itemIndex > 0 && - items[itemIndex - 1] != null && - (itemIndex - 1) % 2 == 0 - ) { + if (items[itemIndex]?.fullPage == true && + itemIndex > 0 && + items[itemIndex - 1] != null && + (itemIndex - 1) % 2 == 0) { // If a page is a full page, check if the previous page needs to be // isolated // we should check if it's an even or odd page, since even pages need @@ -327,14 +315,12 @@ class PagerViewerAdapter(private val viewer: PagerViewer) : ViewPagerAdapter() { } otherItems.getOrNull(pagedIndex)?.let { val lastPage = subJoinedItems.lastOrNull()?.first as? ReaderPage - if ( - lastPage == null || - (if (it is ChapterTransition.Next) { - it.from.chapter.id == lastPage.chapter.chapter.id - } else { - true - }) - ) { + if (lastPage == null || + (if (it is ChapterTransition.Next) { + it.from.chapter.id == lastPage.chapter.chapter.id + } else { + true + })) { subJoinedItems.add(Pair(it, null)) pagedIndex++ } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonAdapter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonAdapter.kt index d761d31bc3..c9fc66cab3 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonAdapter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonAdapter.kt @@ -42,11 +42,9 @@ class WebtoonAdapter(val viewer: WebtoonViewer) : RecyclerView.Adapter { + ViewGroup.MarginLayoutParams> { height = appBarHeight + systemInsets.top } val bigToolbarHeight = fullAppBarHeight ?: 0 @@ -294,10 +293,8 @@ class RecentsController(bundle: Bundle? = null) : override fun onStateChanged(p0: View, state: Int) { if (this@RecentsController.view == null) return - if ( - state == BottomSheetBehavior.STATE_EXPANDED || - state == BottomSheetBehavior.STATE_COLLAPSED - ) { + if (state == BottomSheetBehavior.STATE_EXPANDED || + state == BottomSheetBehavior.STATE_COLLAPSED) { showingDownloads = state == BottomSheetBehavior.STATE_EXPANDED updateTitleAndMenu() } @@ -342,8 +339,7 @@ class RecentsController(bundle: Bundle? = null) : binding.downloadBottomSheet.sheetLayout.isFocusable = state == BottomSheetBehavior.STATE_COLLAPSED setPadding( - binding.downloadBottomSheet.dlBottomSheet.sheetBehavior?.isHideable == true - ) + binding.downloadBottomSheet.dlBottomSheet.sheetBehavior?.isHideable == true) } }, ) @@ -398,8 +394,7 @@ class RecentsController(bundle: Bundle? = null) : binding.downloadBottomSheet.sheetToolbar.title = view?.context?.getString(R.string.download_queue) binding.downloadBottomSheet.sheetToolbar.overflowIcon?.setTint( - view?.context?.getResourceColor(R.attr.actionBarTintColor) ?: Color.BLACK - ) + view?.context?.getResourceColor(R.attr.actionBarTintColor) ?: Color.BLACK) binding.downloadBottomSheet.sheetToolbar.setOnMenuItemClickListener { item -> return@setOnMenuItemClickListener binding.downloadBottomSheet.dlBottomSheet .onOptionsItemSelected(item) @@ -536,11 +531,9 @@ class RecentsController(bundle: Bundle? = null) : if (isControllerVisible) { activityBinding?.appBar?.lockYPos = false } - if ( - !hasNewItems || - presenter.viewType == RecentsPresenter.VIEW_TYPE_GROUP_ALL || - recents.isEmpty() - ) { + if (!hasNewItems || + presenter.viewType == RecentsPresenter.VIEW_TYPE_GROUP_ALL || + recents.isEmpty()) { loadNoMore() } else if (hasNewItems && presenter.viewType != RecentsPresenter.VIEW_TYPE_GROUP_ALL) { resetProgressItem() @@ -805,9 +798,7 @@ class RecentsController(bundle: Bundle? = null) : val lastController = router.backstack.lastOrNull()?.controller if (lastController !is DialogController) { (activity as? MainActivity)?.showTabBar( - show = false, - animate = lastController !is SmallToolbarInterface - ) + show = false, animate = lastController !is SmallToolbarInterface) } snack?.dismiss() } @@ -828,10 +819,8 @@ class RecentsController(bundle: Bundle? = null) : override fun showSheet() { if (!isBindingInitialized) return - if ( - binding.downloadBottomSheet.dlBottomSheet.sheetBehavior?.isHideable == false || - hasQueue() - ) { + if (binding.downloadBottomSheet.dlBottomSheet.sheetBehavior?.isHideable == false || + hasQueue()) { binding.downloadBottomSheet.dlBottomSheet.sheetBehavior?.expand() } } @@ -879,11 +868,9 @@ class RecentsController(bundle: Bundle? = null) : override fun onLoadMore(lastPosition: Int, currentPage: Int) { val view = view ?: return - if ( - presenter.finished || - BackupRestoreJob.isRunning(view.context.applicationContext) || - (presenter.viewType == RecentsPresenter.VIEW_TYPE_GROUP_ALL && !isSearching()) - ) { + if (presenter.finished || + BackupRestoreJob.isRunning(view.context.applicationContext) || + (presenter.viewType == RecentsPresenter.VIEW_TYPE_GROUP_ALL && !isSearching())) { loadNoMore() return } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsPresenter.kt index ffe5468c09..145eab15ff 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsPresenter.kt @@ -220,19 +220,16 @@ class RecentsPresenter( cReading .filterBlockedScanlators(blockedScanlators) .distinctBy { - if ( - query.isEmpty() && - viewType != VIEW_TYPE_ONLY_HISTORY && - viewType != VIEW_TYPE_ONLY_UPDATES - ) + if (query.isEmpty() && + viewType != VIEW_TYPE_ONLY_HISTORY && + viewType != VIEW_TYPE_ONLY_UPDATES) it.manga.id else it.chapter.id } .filter { mch -> if (updatePageCount && !isOnFirstPage && query.isEmpty()) { - if ( - viewType != VIEW_TYPE_ONLY_HISTORY && viewType != VIEW_TYPE_ONLY_UPDATES - ) { + if (viewType != VIEW_TYPE_ONLY_HISTORY && + viewType != VIEW_TYPE_ONLY_UPDATES) { recentItems.none { mch.manga.id == it.mch.manga.id } } else { recentItems.none { mch.chapter.id == it.mch.chapter.id } @@ -256,10 +253,8 @@ class RecentsPresenter( } it.history.id == null -> { getFirstUpdatedChapter(it.manga, it.chapter) - ?: if ( - (showRead && it.chapter.id != null) || - viewType == VIEW_TYPE_ONLY_UPDATES - ) + ?: if ((showRead && it.chapter.id != null) || + viewType == VIEW_TYPE_ONLY_UPDATES) it.chapter else null } @@ -268,10 +263,8 @@ class RecentsPresenter( } } if (chapter == null) - if ( - (query.isNotEmpty() || viewType > VIEW_TYPE_UNGROUP_ALL) && - it.chapter.id != null - ) { + if ((query.isNotEmpty() || viewType > VIEW_TYPE_UNGROUP_ALL) && + it.chapter.id != null) { Pair(it, it.chapter) } else { null @@ -287,10 +280,8 @@ class RecentsPresenter( .asSequence() .filter { it.first.history.id == null && it.first.chapter.id != null } .sortedWith { f1, f2 -> - if ( - abs(f1.second.date_fetch - f2.second.date_fetch) <= - TimeUnit.HOURS.toMillis(12) - ) { + if (abs(f1.second.date_fetch - f2.second.date_fetch) <= + TimeUnit.HOURS.toMillis(12)) { f2.second.date_upload.compareTo(f1.second.date_upload) } else { f2.second.date_fetch.compareTo(f1.second.date_fetch) @@ -363,12 +354,10 @@ class RecentsPresenter( } val newCount = itemCount + newItems.size val hasNewItems = newItems.isNotEmpty() - if ( - updatePageCount && - newCount < 25 && - (viewType != VIEW_TYPE_GROUP_ALL || query.isNotEmpty()) && - !limit - ) { + if (updatePageCount && + newCount < 25 && + (viewType != VIEW_TYPE_GROUP_ALL || query.isNotEmpty()) && + !limit) { runRecents(oldQuery, true, retryCount + (if (hasNewItems) 0 else 1), newCount) return } @@ -529,10 +518,7 @@ class RecentsPresenter( } if (preferences.readingSync().get() && !chapter.isMergedChapter()) { statusHandler.marksChaptersStatus( - manga.uuid(), - listOf(chapter.mangadex_chapter_id), - read - ) + manga.uuid(), listOf(chapter.mangadex_chapter_id), read) } db.updateChaptersProgress(listOf(chapter)).executeAsBlocking() getRecents() diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recents/options/RecentsGeneralView.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recents/options/RecentsGeneralView.kt index eca8b71843..bae6149946 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recents/options/RecentsGeneralView.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recents/options/RecentsGeneralView.kt @@ -18,9 +18,7 @@ class RecentsGeneralView @JvmOverloads constructor(context: Context, attrs: Attr val uniformText = context.getString(R.string.uniform_covers) binding.showRemoveHistory.text = titleText.withSubtitle( - binding.showRemoveHistory.context, - R.string.press_and_hold_to_also_reset - ) + binding.showRemoveHistory.context, R.string.press_and_hold_to_also_reset) binding.uniformCovers.text = uniformText.withSubtitle(binding.uniformCovers.context, R.string.affects_library_grid) binding.showRecentsDownload.bindToPreference(preferences.showRecentsDownloads()) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/security/BiometricActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/security/BiometricActivity.kt index f840d512e3..98fb536abf 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/security/BiometricActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/security/BiometricActivity.kt @@ -50,8 +50,7 @@ class BiometricActivity : BaseThemedActivity() { .setTitle(getString(R.string.unlock_library)) .setAllowedAuthenticators( BiometricManager.Authenticators.DEVICE_CREDENTIAL or - BiometricManager.Authenticators.BIOMETRIC_WEAK - ) + BiometricManager.Authenticators.BIOMETRIC_WEAK) .build() biometricPrompt.authenticate(promptInfo) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/security/SecureActivityDelegate.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/security/SecureActivityDelegate.kt index 9d141972f7..a2ca48a9f0 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/security/SecureActivityDelegate.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/security/SecureActivityDelegate.kt @@ -40,14 +40,12 @@ object SecureActivityDelegate { fun promptLockIfNeeded(activity: Activity?, requireSuccess: Boolean = false) { if (activity == null || AuthenticatorUtil.isAuthenticating) return val lockApp = securityPreferences.useBiometrics().get() - if ( - lockApp && - BiometricManager.from(activity) - .canAuthenticate( - BiometricManager.Authenticators.DEVICE_CREDENTIAL or - BiometricManager.Authenticators.BIOMETRIC_WEAK - ) == BiometricManager.BIOMETRIC_SUCCESS - ) { + if (lockApp && + BiometricManager.from(activity) + .canAuthenticate( + BiometricManager.Authenticators.DEVICE_CREDENTIAL or + BiometricManager.Authenticators.BIOMETRIC_WEAK) == + BiometricManager.BIOMETRIC_SUCCESS) { if (isAppLocked()) { val intent = Intent(activity, BiometricActivity::class.java) intent.putExtra("fromSearch", (activity is SearchActivity) && !requireSuccess) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAdvancedController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAdvancedController.kt index 9c7a69509c..64fa46bd06 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAdvancedController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAdvancedController.kt @@ -399,8 +399,7 @@ class SettingsAdvancedController : SettingsController() { .create() .apply { this.disableItems( - arrayOf(activity!!.getString(R.string.clean_orphaned_downloads)) - ) + arrayOf(activity!!.getString(R.string.clean_orphaned_downloads))) } } } @@ -494,15 +493,13 @@ class SettingsAdvancedController : SettingsController() { .materialAlertDialog() .setCustomTitleAndMessage( R.string.clear_database_confirmation_title, - activity!!.getString(R.string.clear_database_confirmation) - ) + activity!!.getString(R.string.clear_database_confirmation)) .setMultiChoiceItems(item, selected) { _, which, checked -> selected[which] = checked } .setPositiveButton(android.R.string.ok) { _, _ -> (targetController as? SettingsAdvancedController)?.clearDatabase( - selected.last() - ) + selected.last()) } .setNegativeButton(android.R.string.cancel, null) .create() diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsController.kt index f7f56d8450..fa4bd87b4d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsController.kt @@ -109,8 +109,7 @@ abstract class SettingsController : PreferenceController() { ValueAnimator.ofObject( ArgbEvaluator(), Color.TRANSPARENT, - view.context.getResourceColor(R.attr.colorControlHighlight) - ) + view.context.getResourceColor(R.attr.colorControlHighlight)) .apply { duration = 500L repeatCount = 2 diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsDataController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsDataController.kt index 318ccf51b4..f51d761ab1 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsDataController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsDataController.kt @@ -198,8 +198,7 @@ class SettingsDataController : SettingsController() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { putExtra( DocumentsContract.EXTRA_INITIAL_URI, - storageManager.getBackupDirectory()!!.uri - ) + storageManager.getBackupDirectory()!!.uri) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsDownloadController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsDownloadController.kt index 0c27c12af5..4835cafc0b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsDownloadController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsDownloadController.kt @@ -96,25 +96,13 @@ class SettingsDownloadController : SettingsController() { listOf( context.getString(R.string.never), context.resources.getQuantityString( - R.plurals.next_unread_chapters, - 2, - 2 - ), + R.plurals.next_unread_chapters, 2, 2), context.resources.getQuantityString( - R.plurals.next_unread_chapters, - 3, - 3 - ), + R.plurals.next_unread_chapters, 3, 3), context.resources.getQuantityString( - R.plurals.next_unread_chapters, - 5, - 5 - ), + R.plurals.next_unread_chapters, 5, 5), context.resources.getQuantityString( - R.plurals.next_unread_chapters, - 10, - 10 - ), + R.plurals.next_unread_chapters, 10, 10), ) entryValues = listOf(0, 2, 3, 5, 10) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsGeneralController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsGeneralController.kt index b3d5fc401a..e467ddc9ad 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsGeneralController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsGeneralController.kt @@ -131,8 +131,7 @@ class SettingsGeneralController : SettingsController() { arrayOf( R.string.over_any_network, R.string.over_wifi_only, - R.string.dont_auto_update - ) + R.string.dont_auto_update) defaultValue = AppDownloadInstallJob.ONLY_ON_UNMETERED } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsLibraryController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsLibraryController.kt index 7411fe01f8..70b7a764cb 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsLibraryController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsLibraryController.kt @@ -57,10 +57,7 @@ class SettingsLibraryController : SettingsController() { if (it) { launchIO { LibraryPresenter.setSearchSuggestion( - libraryPreferences, - db, - Injekt.get() - ) + libraryPreferences, db, Injekt.get()) } } else { DelayedLibrarySuggestionsJob.setupTask(context, false) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsMainController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsMainController.kt index c761938dbc..73617be1ed 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsMainController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsMainController.kt @@ -29,9 +29,7 @@ class SettingsMainController : SettingsController(), FloatingSearchInterface { preference { iconDrawable = MaterialDesignDx.Icon.gmf_tune.create( - context, - colorAttr = R.attr.colorOnSurface - ) + context, colorAttr = R.attr.colorOnSurface) titleRes = R.string.general onClick { navigateTo(SettingsGeneralController()) } } @@ -106,9 +104,7 @@ class SettingsMainController : SettingsController(), FloatingSearchInterface { preference { iconDrawable = MaterialDesignDx.Icon.gmf_sync.create( - context, - colorAttr = R.attr.colorOnSurface - ) + context, colorAttr = R.attr.colorOnSurface) titleRes = R.string.tracking onClick { navigateTo(SettingsTrackingController()) } } @@ -124,9 +120,7 @@ class SettingsMainController : SettingsController(), FloatingSearchInterface { preference { iconDrawable = MaterialDesignDx.Icon.gmf_code.create( - context, - colorAttr = R.attr.colorOnSurface - ) + context, colorAttr = R.attr.colorOnSurface) titleRes = R.string.advanced onClick { navigateTo(SettingsAdvancedController()) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsTrackingController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsTrackingController.kt index cfd81c0833..70b684b847 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsTrackingController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsTrackingController.kt @@ -65,16 +65,14 @@ class SettingsTrackingController : MdConstants.ContentRating.safe, MdConstants.ContentRating.suggestive, MdConstants.ContentRating.erotica, - MdConstants.ContentRating.pornographic - ) + MdConstants.ContentRating.pornographic) defaultValue = listOf( MdConstants.ContentRating.safe, MdConstants.ContentRating.suggestive, MdConstants.ContentRating.erotica, - MdConstants.ContentRating.pornographic - ) + MdConstants.ContentRating.pornographic) } preference { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/ThemePreference.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/ThemePreference.kt index 4b32b5eb71..e5aeb62e2a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/ThemePreference.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/ThemePreference.kt @@ -98,17 +98,14 @@ class ThemePreference @JvmOverloads constructor(context: Context, attrs: Attribu } if (!selected) { preferences.nightMode().set(nightMode) - } else if ( - preferences.nightMode().get() != AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM - ) { + } else if (preferences.nightMode().get() != + AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM) { preferences.nightMode().set(nightMode) } - if ( - (preferences.nightMode().get() == - AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM && - nightMode != context.appDelegateNightMode()) || - (!selected && nightMode == context.appDelegateNightMode()) - ) { + if ((preferences.nightMode().get() == + AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM && + nightMode != context.appDelegateNightMode()) || + (!selected && nightMode == context.appDelegateNightMode())) { fastAdapterLight.notifyDataSetChanged() fastAdapterDark.notifyDataSetChanged() } else { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/logins/MangaDexLoginActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/logins/MangaDexLoginActivity.kt index 7b683b7b71..e449662e6d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/logins/MangaDexLoginActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/logins/MangaDexLoginActivity.kt @@ -17,8 +17,7 @@ class MangaDexLoginActivity : BaseOAuthLoginActivity() { Toast.makeText( this@MangaDexLoginActivity.applicationContext, R.string.could_not_log_in, - Toast.LENGTH_SHORT - ) + Toast.LENGTH_SHORT) .show() } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/search/SettingsSearchHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/search/SettingsSearchHolder.kt index 6e947ce1c1..682317b2a3 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/search/SettingsSearchHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/search/SettingsSearchHolder.kt @@ -41,9 +41,7 @@ class SettingsSearchHolder(view: View, val adapter: SettingsSearchAdapter) : fun bind(item: SettingsSearchItem) { val color = ColorUtils.setAlphaComponent( - itemView.context.getResourceColor(R.attr.colorSecondary), - 75 - ) + itemView.context.getResourceColor(R.attr.colorSecondary), 75) binding.searchResultPrefTitle.text = item.settingsSearchResult.title.highlightText(item.searchResult, color) binding.searchResultPrefSummary.text = diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/similar/SimilarPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/similar/SimilarPresenter.kt index c930229b13..08c7e2e02e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/similar/SimilarPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/similar/SimilarPresenter.kt @@ -90,8 +90,7 @@ class SimilarPresenter( displayManga = list .associate { group -> group.type to group.manga.toImmutableList() } - .toImmutableMap() - ) + .toImmutableMap()) } } } @@ -174,8 +173,7 @@ class SimilarPresenter( db.getCategories() .executeAsBlocking() .map { category -> category.toCategoryItem() } - .toImmutableList() - ) + .toImmutableList()) } } } @@ -199,9 +197,8 @@ class SimilarPresenter( it.currentArtwork.copy( url = dbManga.user_cover ?: "", originalArtwork = - dbManga.thumbnail_url ?: MdConstants.noCoverUrl - ) - ) + dbManga.thumbnail_url + ?: MdConstants.noCoverUrl)) } .toImmutableList(), ) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/similar/SimilarRepository.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/similar/SimilarRepository.kt index 49ceede298..71c0db01c1 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/similar/SimilarRepository.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/similar/SimilarRepository.kt @@ -112,12 +112,7 @@ class SimilarRepository { } listOfNotNull( - related.await(), - similar.await(), - mu.await(), - anilist.await(), - mal.await() - ) + related.await(), similar.await(), mu.await(), anilist.await(), mal.await()) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/source/browse/BrowseController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/source/browse/BrowseController.kt index 5a4fdfd01f..7e5246978c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/source/browse/BrowseController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/source/browse/BrowseController.kt @@ -59,8 +59,7 @@ class BrowseController(incomingQuery: String = "") : BaseComposeController state.copy(pageLoading = it) } }, onRequest = { browseRepository.getSearchPage( - browseScreenState.value.page, - browseScreenState.value.filters - ) + browseScreenState.value.page, browseScreenState.value.filters) }, getNextKey = { _browseScreenState.value.page + 1 }, onError = { resultError -> @@ -155,8 +153,7 @@ class BrowsePresenter( it.copy( sideNavMode = SideNavMode.findByPrefValue(preferences.sideNavMode().get()), isLoggedIn = browseRepository.isLoggedIn(), - firstLoad = false - ) + firstLoad = false) } } @@ -203,9 +200,7 @@ class BrowsePresenter( filteredDisplayManga = it.displayMangaHolder.allDisplayManga .filterVisibility(preferences) - .toImmutableList() - ) - ) + .toImmutableList())) } } } @@ -226,8 +221,7 @@ class BrowsePresenter( state.copy( error = UiText.String(resultError.message()), initialLoading = false, - hideFooterButton = false - ) + hideFooterButton = false) } } .onSuccess { @@ -235,8 +229,7 @@ class BrowsePresenter( state.copy( homePageManga = it.updateVisibility(preferences), initialLoading = false, - hideFooterButton = false - ) + hideFooterButton = false) } } } @@ -245,11 +238,9 @@ class BrowsePresenter( private fun getFollows(forceUpdate: Boolean) { presenterScope.launchIO { if (!isOnline()) return@launchIO - if ( - forceUpdate || - _browseScreenState.value.displayMangaHolder.resultType != - BrowseScreenType.Follows - ) { + if (forceUpdate || + _browseScreenState.value.displayMangaHolder.resultType != + BrowseScreenType.Follows) { _browseScreenState.update { state -> state.copy(initialLoading = true) } browseRepository .getFollows() @@ -265,8 +256,7 @@ class BrowsePresenter( DisplayMangaHolder( BrowseScreenType.Follows, it.distinctBy { it.url }.toImmutableList(), - it.filterVisibility(preferences).toImmutableList() - ), + it.filterVisibility(preferences).toImmutableList()), initialLoading = false, ) } @@ -311,8 +301,7 @@ class BrowsePresenter( DisplayMangaHolder( resultType = BrowseScreenType.Filter, allDisplayManga = persistentListOf(), - filteredDisplayManga = persistentListOf() - ), + filteredDisplayManga = persistentListOf()), ) } @@ -327,8 +316,7 @@ class BrowsePresenter( _browseScreenState.update { state -> state.copy( error = UiText.String(it.message()), - initialLoading = false - ) + initialLoading = false) } } .onSuccess { dr -> @@ -336,8 +324,7 @@ class BrowsePresenter( it.copy( otherResults = dr.toImmutableList(), screenType = BrowseScreenType.Other, - initialLoading = false - ) + initialLoading = false) } } } @@ -346,8 +333,7 @@ class BrowsePresenter( _browseScreenState.update { state -> state.copy( error = UiText.String("Invalid List UUID"), - initialLoading = false - ) + initialLoading = false) } } else { browseRepository @@ -356,8 +342,7 @@ class BrowsePresenter( _browseScreenState.update { state -> state.copy( error = UiText.String(it.message()), - initialLoading = false - ) + initialLoading = false) } } .onSuccess { allDisplayManga -> @@ -384,23 +369,19 @@ class BrowsePresenter( } } else -> { - if ( - _browseScreenState.value.filters.authorId.isNotBlankAndInvalidUUID() - ) { + if (_browseScreenState.value.filters.authorId + .isNotBlankAndInvalidUUID()) { _browseScreenState.update { state -> state.copy( error = UiText.String("Invalid Author UUID"), - initialLoading = false - ) + initialLoading = false) } - } else if ( - _browseScreenState.value.filters.groupId.isNotBlankAndInvalidUUID() - ) { + } else if (_browseScreenState.value.filters.groupId + .isNotBlankAndInvalidUUID()) { _browseScreenState.update { state -> state.copy( error = UiText.String("Invalid Group UUID"), - initialLoading = false - ) + initialLoading = false) } } else { paginator.loadNextItems() @@ -414,8 +395,7 @@ class BrowsePresenter( isDeepLink = true, title = UiText.String(""), initialLoading = false, - error = UiText.String(uuid) - ) + error = UiText.String(uuid)) } } DeepLinkType.Manga -> { @@ -427,24 +407,18 @@ class BrowsePresenter( .onFailure { _browseScreenState.update { state -> state.copy( - error = UiText.String(it.message()), - initialLoading = false - ) + error = UiText.String(it.message()), initialLoading = false) } } .onSuccess { dm -> - if ( - incomingQuery.isNotBlank() && - !_browseScreenState.value.handledIncomingQuery - ) { + if (incomingQuery.isNotBlank() && + !_browseScreenState.value.handledIncomingQuery) { _browseScreenState.update { it.copy( filters = it.filters.copy( - query = Filter.Query("", QueryType.Title) - ), - handledIncomingQuery = true - ) + query = Filter.Query("", QueryType.Title)), + handledIncomingQuery = true) } } view?.openManga(dm.mangaId, true) @@ -458,8 +432,7 @@ class BrowsePresenter( createInitialDexFilter("") .copy( queryMode = QueryType.List, - query = Filter.Query(text = uuid, type = QueryType.List) - ) + query = Filter.Query(text = uuid, type = QueryType.List)) _browseScreenState.update { it.copy(filters = searchFilters) } if (!_browseScreenState.value.handledIncomingQuery) { _browseScreenState.update { it.copy(handledIncomingQuery = true) } @@ -469,9 +442,7 @@ class BrowsePresenter( .onFailure { _browseScreenState.update { state -> state.copy( - error = UiText.String(it.message()), - initialLoading = false - ) + error = UiText.String(it.message()), initialLoading = false) } } .onSuccess { allDisplayManga -> @@ -509,8 +480,7 @@ class BrowsePresenter( _browseScreenState.update { it.copy( isDeepLink = true, - title = UiText.StringResource(R.string.scanlator_group) - ) + title = UiText.StringResource(R.string.scanlator_group)) } val searchFilters = createInitialDexFilter("").copy(groupId = Filter.GroupId(uuid = uuid)) @@ -637,8 +607,7 @@ class BrowsePresenter( it.copy( displayMangaHolder = it.displayMangaHolder.copy( - allDisplayManga = tempList.toPersistentList() - ), + allDisplayManga = tempList.toPersistentList()), ) } @@ -655,8 +624,7 @@ class BrowsePresenter( it.copy( displayMangaHolder = it.displayMangaHolder.copy( - filteredDisplayManga = tempFilterList.toPersistentList() - ), + filteredDisplayManga = tempFilterList.toPersistentList()), ) } } @@ -750,9 +718,7 @@ class BrowsePresenter( filters = blankFilter.copy( queryMode = QueryType.Author, - query = Filter.Query(creator, QueryType.Author) - ) - ) + query = Filter.Query(creator, QueryType.Author))) } getSearchPage() @@ -768,15 +734,13 @@ class BrowsePresenter( lookupAndReplaceEntry( browseScreenState.value.filters.contentRatings, { it.rating == newFilter.rating }, - newFilter - ) + newFilter) if (list.none { it.state }) { val default = lookupAndReplaceEntry( list, { it.rating == MangaContentRating.Safe }, - Filter.ContentRating(MangaContentRating.Safe, true) - ) + Filter.ContentRating(MangaContentRating.Safe, true)) browseScreenState.value.filters.copy(contentRatings = default) } else { browseScreenState.value.filters.copy(contentRatings = list) @@ -787,8 +751,7 @@ class BrowsePresenter( lookupAndReplaceEntry( browseScreenState.value.filters.originalLanguage, { it.language == newFilter.language }, - newFilter - ) + newFilter) browseScreenState.value.filters.copy(originalLanguage = list) } is Filter.PublicationDemographic -> { @@ -796,8 +759,7 @@ class BrowsePresenter( lookupAndReplaceEntry( browseScreenState.value.filters.publicationDemographics, { it.demographic == newFilter.demographic }, - newFilter - ) + newFilter) browseScreenState.value.filters.copy(publicationDemographics = list) } is Filter.Status -> { @@ -805,8 +767,7 @@ class BrowsePresenter( lookupAndReplaceEntry( browseScreenState.value.filters.statuses, { it.status == newFilter.status }, - newFilter - ) + newFilter) browseScreenState.value.filters.copy(statuses = list) } is Filter.Tag -> { @@ -814,8 +775,7 @@ class BrowsePresenter( lookupAndReplaceEntry( browseScreenState.value.filters.tags, { it.tag == newFilter.tag }, - newFilter - ) + newFilter) browseScreenState.value.filters.copy(tags = list) } is Filter.Sort -> { @@ -826,8 +786,7 @@ class BrowsePresenter( } browseScreenState.value.filters.copy( - sort = Filter.Sort.getSortList(filterMode) - ) + sort = Filter.Sort.getSortList(filterMode)) } is Filter.HasAvailableChapters -> { browseScreenState.value.filters.copy(hasAvailableChapters = newFilter) @@ -842,27 +801,19 @@ class BrowsePresenter( when (newFilter.type) { QueryType.Title -> { browseScreenState.value.filters.copy( - queryMode = QueryType.Title, - query = newFilter - ) + queryMode = QueryType.Title, query = newFilter) } QueryType.Author -> { browseScreenState.value.filters.copy( - queryMode = QueryType.Author, - query = newFilter - ) + queryMode = QueryType.Author, query = newFilter) } QueryType.Group -> { browseScreenState.value.filters.copy( - queryMode = QueryType.Group, - query = newFilter - ) + queryMode = QueryType.Group, query = newFilter) } QueryType.List -> { browseScreenState.value.filters.copy( - queryMode = QueryType.List, - query = newFilter - ) + queryMode = QueryType.List, query = newFilter) } } } @@ -900,8 +851,7 @@ class BrowsePresenter( db.getCategories() .executeAsBlocking() .map { category -> category.toCategoryItem() } - .toPersistentList() - ) + .toPersistentList()) } } } @@ -973,8 +923,7 @@ class BrowsePresenter( _browseScreenState.update { it.copy( initialLoading = false, - error = UiText.StringResource(R.string.no_network_connection) - ) + error = UiText.StringResource(R.string.no_network_connection)) } } false diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/source/latest/DisplayPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/source/latest/DisplayPresenter.kt index eaa2d32468..bf0eb05135 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/source/latest/DisplayPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/source/latest/DisplayPresenter.kt @@ -116,8 +116,7 @@ class DisplayPresenter( it.copy( showLibraryEntries = show, filteredDisplayManga = - it.allDisplayManga.filterVisibility(preferences).toImmutableList() - ) + it.allDisplayManga.filterVisibility(preferences).toImmutableList()) } } } @@ -194,8 +193,7 @@ class DisplayPresenter( _displayScreenState.update { it.copy( filteredDisplayManga = - it.allDisplayManga.filterVisibility(preferences).toImmutableList() - ) + it.allDisplayManga.filterVisibility(preferences).toImmutableList()) } } } @@ -212,8 +210,7 @@ class DisplayPresenter( db.getCategories() .executeAsBlocking() .map { category -> category.toCategoryItem() } - .toImmutableList() - ) + .toImmutableList()) } } } @@ -234,8 +231,7 @@ class DisplayPresenter( it.copy( allDisplayManga = newDisplayManga, filteredDisplayManga = - newDisplayManga.filterVisibility(preferences).toImmutableList() - ) + newDisplayManga.filterVisibility(preferences).toImmutableList()) } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/ChapterExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/util/ChapterExtensions.kt index 9d17044cc2..2adfcdbafd 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/ChapterExtensions.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/ChapterExtensions.kt @@ -47,11 +47,9 @@ fun List.getMissingChapters(): MissingChapterHolder { chapterNumberArray.forEachIndexed { index, chpNum -> val lastIndex = index - 1 - if ( - lastIndex >= 0 && - (chpNum - 1) > chapterNumberArray[lastIndex] && - chapterNumberArray[lastIndex] > 0 - ) { + if (lastIndex >= 0 && + (chpNum - 1) > chapterNumberArray[lastIndex] && + chapterNumberArray[lastIndex] > 0) { count += (chpNum - chapterNumberArray[lastIndex]) - 1 val beginningChp = (chapterNumberArray[lastIndex] + 1) val endChap = chpNum - 1 diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/CrashLogUtil.kt b/app/src/main/java/eu/kanade/tachiyomi/util/CrashLogUtil.kt index ea60ada66d..c9a5756f48 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/CrashLogUtil.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/CrashLogUtil.kt @@ -45,8 +45,8 @@ class CrashLogUtil(private val context: Context) { storageManager .getCrashLogDirectory() ?.createFile( - "neko_crash_log-${SimpleDateFormat("yyyyMMddHHmm").format(Date())}.txt" - ) ?: return@withNonCancellableContext + "neko_crash_log-${SimpleDateFormat("yyyyMMddHHmm").format(Date())}.txt") + ?: return@withNonCancellableContext uniFile .openOutputStream() diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/MangaExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/util/MangaExtensions.kt index 204bc049d0..f63b12481e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/MangaExtensions.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/MangaExtensions.kt @@ -113,8 +113,7 @@ fun Manga.toDisplayManga( currentArtwork = Artwork( mangaId = this.id!!, - originalArtwork = this.thumbnail_url ?: MdConstants.noCoverUrl - ), + originalArtwork = this.thumbnail_url ?: MdConstants.noCoverUrl), ) } @@ -161,9 +160,7 @@ fun List.resync(db: DatabaseHelper): List { currentArtwork = displayManga.currentArtwork.copy( url = dbManga.user_cover ?: "", - originalArtwork = dbManga.thumbnail_url ?: MdConstants.noCoverUrl - ) - ) + originalArtwork = dbManga.thumbnail_url ?: MdConstants.noCoverUrl)) } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/chapter/ChapterFilter.kt b/app/src/main/java/eu/kanade/tachiyomi/util/chapter/ChapterFilter.kt index c48fbad049..8364d75cb6 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/chapter/ChapterFilter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/chapter/ChapterFilter.kt @@ -33,14 +33,12 @@ class ChapterFilter( // if none of the filters are enabled skip the filtering of them val filteredChapters = filterChaptersByScanlators(chapters, manga) - return if ( - readEnabled || - unreadEnabled || - downloadEnabled || - notDownloadEnabled || - bookmarkEnabled || - notBookmarkEnabled - ) { + return if (readEnabled || + unreadEnabled || + downloadEnabled || + notDownloadEnabled || + bookmarkEnabled || + notBookmarkEnabled) { filteredChapters.filter { return@filter !(readEnabled && !it.read || (unreadEnabled && it.read) || @@ -78,11 +76,9 @@ class ChapterFilter( } // if filter preferences are not enabled don't even filter - if ( - !readerPreferences.skipRead().get() && - !readerPreferences.skipFiltered().get() && - !readerPreferences.skipDuplicates().get() - ) { + if (!readerPreferences.skipRead().get() && + !readerPreferences.skipFiltered().get() && + !readerPreferences.skipDuplicates().get()) { return filteredChapters } diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/chapter/ChapterItemFilter.kt b/app/src/main/java/eu/kanade/tachiyomi/util/chapter/ChapterItemFilter.kt index 022571d33a..5e5548718c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/chapter/ChapterItemFilter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/chapter/ChapterItemFilter.kt @@ -32,26 +32,22 @@ class ChapterItemFilter( // if none of the filters are enabled skip the filtering of them val filteredChapters = filterChaptersByLanguage(filterChaptersByScanlators(chapters, manga), manga) - return if ( - readEnabled || - unreadEnabled || - downloadEnabled || - notDownloadEnabled || - bookmarkEnabled || - notBookmarkEnabled - ) { + return if (readEnabled || + unreadEnabled || + downloadEnabled || + notDownloadEnabled || + bookmarkEnabled || + notBookmarkEnabled) { filteredChapters.filter { chapterItem -> val chapter = chapterItem.chapter - if ( - readEnabled && !chapter.read || - (unreadEnabled && chapter.read) || - (bookmarkEnabled && !chapter.bookmark) || - (notBookmarkEnabled && chapter.bookmark) || - (downloadEnabled && - !downloadManager.isChapterDownloaded(chapter.toDbChapter(), manga)) || - (notDownloadEnabled && - downloadManager.isChapterDownloaded(chapter.toDbChapter(), manga)) - ) { + if (readEnabled && !chapter.read || + (unreadEnabled && chapter.read) || + (bookmarkEnabled && !chapter.bookmark) || + (notBookmarkEnabled && chapter.bookmark) || + (downloadEnabled && + !downloadManager.isChapterDownloaded(chapter.toDbChapter(), manga)) || + (notDownloadEnabled && + downloadManager.isChapterDownloaded(chapter.toDbChapter(), manga))) { return@filter false } return@filter true diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/chapter/ChapterSourceSync.kt b/app/src/main/java/eu/kanade/tachiyomi/util/chapter/ChapterSourceSync.kt index de0d1fe8a1..d8e1065a53 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/chapter/ChapterSourceSync.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/chapter/ChapterSourceSync.kt @@ -74,13 +74,11 @@ fun syncChaptersWithSource( ChapterRecognition.parseChapterNumber(sourceChapter, manga) if (shouldUpdateDbChapter(dbChapter, sourceChapter)) { - if ( - dbChapter.name != sourceChapter.name && - downloadManager.isChapterDownloaded( - dbChapter, - manga, - ) - ) { + if (dbChapter.name != sourceChapter.name && + downloadManager.isChapterDownloaded( + dbChapter, + manga, + )) { downloadManager.renameChapter(manga, dbChapter, sourceChapter) } dbChapter.scanlator = sourceChapter.scanlator diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/manga/MangaShortcutManager.kt b/app/src/main/java/eu/kanade/tachiyomi/util/manga/MangaShortcutManager.kt index d71d468c87..c7339c0fdb 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/manga/MangaShortcutManager.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/manga/MangaShortcutManager.kt @@ -76,10 +76,8 @@ class MangaShortcutManager( ) .setIcon( if (bitmap != null) - if ( - android.os.Build.VERSION.SDK_INT >= - android.os.Build.VERSION_CODES.O - ) { + if (android.os.Build.VERSION.SDK_INT >= + android.os.Build.VERSION_CODES.O) { Icon.createWithAdaptiveBitmap(bitmap.toSquare()) } else { Icon.createWithBitmap(bitmap) @@ -92,8 +90,7 @@ class MangaShortcutManager( SearchActivity.openMangaIntent(context, item.id, true) .addFlags( Intent.FLAG_ACTIVITY_CLEAR_TOP or - Intent.FLAG_ACTIVITY_SINGLE_TOP - ), + Intent.FLAG_ACTIVITY_SINGLE_TOP), ) .build() } diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/system/AuthenticatorUtil.kt b/app/src/main/java/eu/kanade/tachiyomi/util/system/AuthenticatorUtil.kt index 7f02edce11..c1b094b866 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/system/AuthenticatorUtil.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/system/AuthenticatorUtil.kt @@ -46,8 +46,7 @@ object AuthenticatorUtil { .setSubtitle(subtitle) .setAllowedAuthenticators( BiometricManager.Authenticators.DEVICE_CREDENTIAL or - BiometricManager.Authenticators.BIOMETRIC_WEAK - ) + BiometricManager.Authenticators.BIOMETRIC_WEAK) .setConfirmationRequired(confirmationRequired) .build() diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/system/GLUtil.kt b/app/src/main/java/eu/kanade/tachiyomi/util/system/GLUtil.kt index 219a6cdc69..1cbe002fd6 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/system/GLUtil.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/system/GLUtil.kt @@ -27,11 +27,7 @@ class GLUtil private constructor() { // Query actual list configurations val configurationsList = arrayOfNulls(totalConfigurations[0]) egl.eglGetConfigs( - display, - configurationsList, - totalConfigurations[0], - totalConfigurations - ) + display, configurationsList, totalConfigurations[0], totalConfigurations) val textureSize = IntArray(1) var maximumTextureSize = 0 @@ -40,11 +36,7 @@ class GLUtil private constructor() { for (i in 0 until totalConfigurations[0]) { // Only need to check for width since opengl textures are always squared egl.eglGetConfigAttrib( - display, - configurationsList[i], - EGL10.EGL_MAX_PBUFFER_WIDTH, - textureSize - ) + display, configurationsList[i], EGL10.EGL_MAX_PBUFFER_WIDTH, textureSize) // Keep track of the maximum texture size if (maximumTextureSize < textureSize[0]) maximumTextureSize = textureSize[0] diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/system/ImageUtil.kt b/app/src/main/java/eu/kanade/tachiyomi/util/system/ImageUtil.kt index 66eefd9f87..3696cba064 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/system/ImageUtil.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/system/ImageUtil.kt @@ -186,29 +186,25 @@ object ImageUtil { (topRightIsDark && (botRightIsDark || botLeftIsDark || midRightIsDark || topMidIsDark)) - if ( - !image.getPixel(left, top).isWhite && - pixelIsClose(image.getPixel(left, top), image.getPixel(midX, top)) && - !image.getPixel(right, top).isWhite && - pixelIsClose(image.getPixel(right, top), image.getPixel(right, bot)) && - !image.getPixel(right, bot).isWhite && - pixelIsClose(image.getPixel(right, bot), image.getPixel(midX, bot)) && - !image.getPixel(midX, top).isWhite && - pixelIsClose(image.getPixel(midX, top), image.getPixel(right, top)) && - !image.getPixel(midX, bot).isWhite && - pixelIsClose(image.getPixel(midX, bot), image.getPixel(left, bot)) && - !image.getPixel(left, bot).isWhite && - pixelIsClose(image.getPixel(left, bot), image.getPixel(left, top)) - ) { + if (!image.getPixel(left, top).isWhite && + pixelIsClose(image.getPixel(left, top), image.getPixel(midX, top)) && + !image.getPixel(right, top).isWhite && + pixelIsClose(image.getPixel(right, top), image.getPixel(right, bot)) && + !image.getPixel(right, bot).isWhite && + pixelIsClose(image.getPixel(right, bot), image.getPixel(midX, bot)) && + !image.getPixel(midX, top).isWhite && + pixelIsClose(image.getPixel(midX, top), image.getPixel(right, top)) && + !image.getPixel(midX, bot).isWhite && + pixelIsClose(image.getPixel(midX, bot), image.getPixel(left, bot)) && + !image.getPixel(left, bot).isWhite && + pixelIsClose(image.getPixel(left, bot), image.getPixel(left, top))) { return ColorDrawable(image.getPixel(left, top)) } - if ( - image.getPixel(left, top).isWhite.toInt() + - image.getPixel(right, top).isWhite.toInt() + - image.getPixel(left, bot).isWhite.toInt() + - image.getPixel(right, bot).isWhite.toInt() > 2 - ) { + if (image.getPixel(left, top).isWhite.toInt() + + image.getPixel(right, top).isWhite.toInt() + + image.getPixel(left, bot).isWhite.toInt() + + image.getPixel(right, bot).isWhite.toInt() > 2) { darkBG = false } @@ -319,20 +315,16 @@ object ImageUtil { val isLandscape = context.resources.configuration?.orientation == Configuration.ORIENTATION_LANDSCAPE if (darkBG) { - return if ( - !isLandscape && - image.getPixel(left, bot).isWhite && - image.getPixel(right, bot).isWhite - ) { + return if (!isLandscape && + image.getPixel(left, bot).isWhite && + image.getPixel(right, bot).isWhite) { GradientDrawable( GradientDrawable.Orientation.TOP_BOTTOM, intArrayOf(blackPixel, blackPixel, backgroundColor, backgroundColor), ) - } else if ( - !isLandscape && - image.getPixel(left, top).isWhite && - image.getPixel(right, top).isWhite - ) { + } else if (!isLandscape && + image.getPixel(left, top).isWhite && + image.getPixel(right, top).isWhite) { GradientDrawable( GradientDrawable.Orientation.TOP_BOTTOM, intArrayOf(backgroundColor, backgroundColor, blackPixel, blackPixel), @@ -341,28 +333,24 @@ object ImageUtil { ColorDrawable(blackPixel) } } - if ( - !isLandscape && - (topIsBlackStreak || - (topLeftIsDark && - topRightIsDark && - image.getPixel(left - offsetX, top).isDark && - image.getPixel(right + offsetX, top).isDark && - (topMidIsDark || overallBlackPixels > 9))) - ) { + if (!isLandscape && + (topIsBlackStreak || + (topLeftIsDark && + topRightIsDark && + image.getPixel(left - offsetX, top).isDark && + image.getPixel(right + offsetX, top).isDark && + (topMidIsDark || overallBlackPixels > 9)))) { return GradientDrawable( GradientDrawable.Orientation.TOP_BOTTOM, intArrayOf(blackPixel, blackPixel, backgroundColor, backgroundColor), ) - } else if ( - !isLandscape && - (bottomIsBlackStreak || - (botLeftIsDark && - botRightIsDark && - image.getPixel(left - offsetX, bot).isDark && - image.getPixel(right + offsetX, bot).isDark && - (image.getPixel(midX, bot).isDark || overallBlackPixels > 9))) - ) { + } else if (!isLandscape && + (bottomIsBlackStreak || + (botLeftIsDark && + botRightIsDark && + image.getPixel(left - offsetX, bot).isDark && + image.getPixel(right + offsetX, bot).isDark && + (image.getPixel(midX, bot).isDark || overallBlackPixels > 9)))) { return GradientDrawable( GradientDrawable.Orientation.TOP_BOTTOM, intArrayOf(backgroundColor, backgroundColor, blackPixel, blackPixel), @@ -402,14 +390,9 @@ object ImageUtil { canvas.drawBitmap( imageBitmap, Rect( - if (!secondHalf) 0 else width / 2, - 0, - if (secondHalf) width else width / 2, - height - ), + if (!secondHalf) 0 else width / 2, 0, if (secondHalf) width else width / 2, height), result.rect, - null - ) + null) progressCallback?.invoke(99) val output = ByteArrayOutputStream() result.compress(Bitmap.CompressFormat.JPEG, 100, output) @@ -521,10 +504,7 @@ object ImageUtil { val result = Bitmap.createBitmap( - width + width2 + gapInPx, - max(height, height2), - Bitmap.Config.ARGB_8888 - ) + width + width2 + gapInPx, max(height, height2), Bitmap.Config.ARGB_8888) val canvas = Canvas(result) canvas.drawColor(background) @@ -579,10 +559,8 @@ object ImageUtil { /** Splits tall images to improve performance of reader */ fun splitTallImage(imageFile: UniFile, imageFilePath: String): Boolean { - if ( - isAnimatedAndSupported(imageFile.openInputStream()) || - !isTallImage(imageFile.openInputStream()) - ) { + if (isAnimatedAndSupported(imageFile.openInputStream()) || + !isTallImage(imageFile.openInputStream())) { return true } diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/system/ThemeUtil.kt b/app/src/main/java/eu/kanade/tachiyomi/util/system/ThemeUtil.kt index 64a3c45484..9a54dc8df9 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/system/ThemeUtil.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/system/ThemeUtil.kt @@ -71,11 +71,9 @@ fun AppCompatActivity.setThemeByPref(preferences: PreferencesHelper) { fun Context.getPrefTheme(preferences: PreferencesHelper): Themes { // Using a try catch in case I start to remove themes return try { - (if ( - (applicationContext.isInNightMode() || - preferences.nightMode().get() == AppCompatDelegate.MODE_NIGHT_YES) && - preferences.nightMode().get() != AppCompatDelegate.MODE_NIGHT_NO - ) { + (if ((applicationContext.isInNightMode() || + preferences.nightMode().get() == AppCompatDelegate.MODE_NIGHT_YES) && + preferences.nightMode().get() != AppCompatDelegate.MODE_NIGHT_NO) { preferences.darkTheme() } else { preferences.lightTheme() diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/view/ControllerExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/util/view/ControllerExtensions.kt index 0d955e779a..c49af3e900 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/view/ControllerExtensions.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/view/ControllerExtensions.kt @@ -72,11 +72,9 @@ fun Controller.setOnQueryTextChangeListener( searchView?.setOnQueryTextListener( object : SearchView.OnQueryTextListener { override fun onQueryTextChange(newText: String?): Boolean { - if ( - !onlyOnSubmit && - router.backstack.lastOrNull()?.controller == - this@setOnQueryTextChangeListener - ) { + if (!onlyOnSubmit && + router.backstack.lastOrNull()?.controller == + this@setOnQueryTextChangeListener) { return f(newText) } return false @@ -224,10 +222,8 @@ fun Controller.liftAppbarWith( object : RecyclerView.OnScrollListener() { override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) { super.onScrolled(recyclerView, dx, dy) - if ( - router?.backstack?.lastOrNull()?.controller == this@liftAppbarWith && - activity != null - ) { + if (router?.backstack?.lastOrNull()?.controller == this@liftAppbarWith && + activity != null) { val notAtTop = recycler.canScrollVertically(-1) if (notAtTop != isToolbarColored) colorToolbar(notAtTop) } @@ -385,11 +381,9 @@ fun Controller.scrollViewWith( activityBinding?.toolbar?.tag = randomTag activityBinding?.toolbar?.setOnClickListener { recycler.smoothScrollToTop() } } else { - if ( - !customPadding && - lastY == 0f && - ((this@scrollViewWith !is FloatingSearchInterface) || includeTabView) - ) { + if (!customPadding && + lastY == 0f && + ((this@scrollViewWith !is FloatingSearchInterface) || includeTabView)) { val parent = recycler.parent as? ViewGroup ?: return val v = View(activity) fakeToolbarView = v @@ -401,12 +395,10 @@ fun Controller.scrollViewWith( v.layoutParams = params onLeavingController?.invoke() } - if ( - !customPadding && - router.backstackSize == 2 && - changeType == ControllerChangeType.PUSH_EXIT && - router.backstack.lastOrNull()?.controller !is DialogController - ) { + if (!customPadding && + router.backstackSize == 2 && + changeType == ControllerChangeType.PUSH_EXIT && + router.backstack.lastOrNull()?.controller !is DialogController) { val parent = recycler.parent as? ViewGroup ?: return val bottomNav = activityBinding?.bottomNav ?: return val v = View(activity) @@ -440,14 +432,12 @@ fun Controller.scrollViewWith( object : RecyclerView.OnScrollListener() { override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) { super.onScrolled(recyclerView, dx, dy) - if ( - isControllerVisible && - statusBarHeight > -1 && - (this@scrollViewWith as? BaseController<*>)?.isDragging != true && - activity != null && - (activityBinding?.appBar?.height ?: 0) > 0 && - recycler.translationY == 0f - ) { + if (isControllerVisible && + statusBarHeight > -1 && + (this@scrollViewWith as? BaseController<*>)?.isDragging != true && + activity != null && + (activityBinding?.appBar?.height ?: 0) > 0 && + recycler.translationY == 0f) { if (!recycler.canScrollVertically(-1)) { val shortAnimationDuration = resources?.getInteger( @@ -488,12 +478,10 @@ fun Controller.scrollViewWith( } } - if ( - !isToolbarColor && - (dy == 0 || - activityBinding?.appBar?.let { it.y <= -it.height.toFloat() } == - true) - ) { + if (!isToolbarColor && + (dy == 0 || + activityBinding?.appBar?.let { it.y <= -it.height.toFloat() } == + true)) { colorToolbar(true) } val notAtTop = !atTopOfRecyclerView() @@ -510,17 +498,13 @@ fun Controller.scrollViewWith( val activityBinding = activityBinding ?: return super.onScrollStateChanged(recyclerView, newState) - if ( - newState == RecyclerView.SCROLL_STATE_IDLE && - (this@scrollViewWith as? BaseController<*>)?.isDragging != true - ) { - if ( - isControllerVisible && - statusBarHeight > -1 && - activity != null && - activityBinding.appBar.height > 0 && - recycler.translationY == 0f - ) { + if (newState == RecyclerView.SCROLL_STATE_IDLE && + (this@scrollViewWith as? BaseController<*>)?.isDragging != true) { + if (isControllerVisible && + statusBarHeight > -1 && + activity != null && + activityBinding.appBar.height > 0 && + recycler.translationY == 0f) { val halfWay = activityBinding.appBar.height.toFloat() / 2 val shortAnimationDuration = resources?.getInteger( @@ -532,10 +516,8 @@ fun Controller.scrollViewWith( activityBinding.bottomNav?.translationY ?: 0f > halfWayBottom val atTop = !recycler.canScrollVertically(-1) val closerToEdge = - if ( - activityBinding.bottomNav?.isVisible == true && - preferences.hideBottomNavOnScroll().get() - ) { + if (activityBinding.bottomNav?.isVisible == true && + preferences.hideBottomNavOnScroll().get()) { closerToBottom } else { closerToTop @@ -551,11 +533,9 @@ fun Controller.scrollViewWith( -appBar.height + appBar.paddingTop.toFloat(), ) } - if ( - activityBinding.bottomNav?.isVisible == true && - isInView && - preferences.hideBottomNavOnScroll().get() - ) { + if (activityBinding.bottomNav?.isVisible == true && + isInView && + preferences.hideBottomNavOnScroll().get()) { activityBinding.bottomNav.let { val lastBottomY = if (closerToEdge && !atTop) it.height.toFloat() else 0f @@ -655,11 +635,9 @@ fun Controller.moveRecyclerViewUp(allTheWayUp: Boolean = false, scrollUpAnyway: val recycler = mainRecyclerView ?: return val activityBinding = activityBinding ?: return val appBarOffset = activityBinding.appBar.toolbarDistanceToTop - if ( - allTheWayUp && - recycler.computeVerticalScrollOffset() - recycler.paddingTop <= - fullAppBarHeight ?: activityBinding.appBar.preLayoutHeight - ) { + if (allTheWayUp && + recycler.computeVerticalScrollOffset() - recycler.paddingTop <= + fullAppBarHeight ?: activityBinding.appBar.preLayoutHeight) { (recycler.layoutManager as? LinearLayoutManager)?.scrollToPosition(0) (recycler.layoutManager as? StaggeredGridLayoutManager)?.scrollToPosition(0) recycler.post { @@ -668,23 +646,16 @@ fun Controller.moveRecyclerViewUp(allTheWayUp: Boolean = false, scrollUpAnyway: } return } - if ( - scrollUpAnyway || - recycler.computeVerticalScrollOffset() - recycler.paddingTop <= 0 - appBarOffset - ) { + if (scrollUpAnyway || + recycler.computeVerticalScrollOffset() - recycler.paddingTop <= 0 - appBarOffset) { (recycler.layoutManager as? LinearLayoutManager)?.scrollToPositionWithOffset( - 0, - activityBinding.appBar.yNeededForSmallToolbar - ) + 0, activityBinding.appBar.yNeededForSmallToolbar) (recycler.layoutManager as? StaggeredGridLayoutManager)?.scrollToPositionWithOffset( - 0, - activityBinding.appBar.yNeededForSmallToolbar - ) + 0, activityBinding.appBar.yNeededForSmallToolbar) recycler.post { activityBinding.appBar.updateAppBarAfterY(recycler) activityBinding.appBar.useSearchToolbarForMenu( - recycler.computeVerticalScrollOffset() != 0 - ) + recycler.computeVerticalScrollOffset() != 0) } } } @@ -696,13 +667,10 @@ fun Controller.setAppBarBG(value: Float, includeTabView: Boolean = false) { if (!isControllerVisible) return if (floatingBar) { (activityBinding?.cardView as? CardView)?.setCardBackgroundColor( - context.getResourceColor(R.attr.colorPrimaryVariant) - ) - if ( - this !is SmallToolbarInterface && - activityBinding?.appBar?.useLargeToolbar == true && - activityBinding?.appBar?.compactSearchMode != true - ) { + context.getResourceColor(R.attr.colorPrimaryVariant)) + if (this !is SmallToolbarInterface && + activityBinding?.appBar?.useLargeToolbar == true && + activityBinding?.appBar?.compactSearchMode != true) { val colorSurface = context.getResourceColor(R.attr.colorSurface) val color = ColorUtils.blendARGB( diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/view/ViewExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/util/view/ViewExtensions.kt index 4516e2964c..c7274fc6f4 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/view/ViewExtensions.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/view/ViewExtensions.kt @@ -459,20 +459,16 @@ fun Dialog.blurBehindWindow( onCancel: DialogInterface.OnCancelListener? = null, ) { var supportsBlur = false - if ( - Build.VERSION.SDK_INT >= Build.VERSION_CODES.S && - window?.windowManager?.isCrossWindowBlurEnabled == true - ) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S && + window?.windowManager?.isCrossWindowBlurEnabled == true) { supportsBlur = true } var registered = true val powerSaverChangeReceiver: BroadcastReceiver = object : BroadcastReceiver() { override fun onReceive(context: Context?, intent: Intent?) { - if ( - Build.VERSION.SDK_INT >= Build.VERSION_CODES.S && - window?.windowManager?.isCrossWindowBlurEnabled == true - ) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S && + window?.windowManager?.isCrossWindowBlurEnabled == true) { return } val canBlur = diff --git a/app/src/main/java/eu/kanade/tachiyomi/widget/AutofitRecyclerView.kt b/app/src/main/java/eu/kanade/tachiyomi/widget/AutofitRecyclerView.kt index fbbd660913..38ceb183d5 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/widget/AutofitRecyclerView.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/widget/AutofitRecyclerView.kt @@ -173,13 +173,11 @@ class AutofitRecyclerView @JvmOverloads constructor(context: Context, attrs: Att } private fun setSpan(force: Boolean = false) { - if ( - (spanCount == 0 || - force || - // Add 100dp check to make sure we dont update span for sidenav changes - (width != lastMeasuredWidth && abs(width - lastMeasuredWidth) > 100.dpToPx)) && - columnWidth > 0 - ) { + if ((spanCount == 0 || + force || + // Add 100dp check to make sure we dont update span for sidenav changes + (width != lastMeasuredWidth && abs(width - lastMeasuredWidth) > 100.dpToPx)) && + columnWidth > 0) { val dpWidth = (width.pxToDp / 100f).roundToInt() val count = max(1, (dpWidth / columnWidth).roundToInt()) spanCount = count diff --git a/app/src/main/java/eu/kanade/tachiyomi/widget/DrawerSwipeCloseListener.kt b/app/src/main/java/eu/kanade/tachiyomi/widget/DrawerSwipeCloseListener.kt index 865e8c5df0..977f08dc84 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/widget/DrawerSwipeCloseListener.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/widget/DrawerSwipeCloseListener.kt @@ -12,18 +12,14 @@ class DrawerSwipeCloseListener( override fun onDrawerOpened(drawerView: View) { if (drawerView == navigationView) { drawer.setDrawerLockMode( - androidx.drawerlayout.widget.DrawerLayout.LOCK_MODE_UNLOCKED, - drawerView - ) + androidx.drawerlayout.widget.DrawerLayout.LOCK_MODE_UNLOCKED, drawerView) } } override fun onDrawerClosed(drawerView: View) { if (drawerView == navigationView) { drawer.setDrawerLockMode( - androidx.drawerlayout.widget.DrawerLayout.LOCK_MODE_LOCKED_CLOSED, - drawerView - ) + androidx.drawerlayout.widget.DrawerLayout.LOCK_MODE_LOCKED_CLOSED, drawerView) } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/widget/E2EBottomSheetDialog.kt b/app/src/main/java/eu/kanade/tachiyomi/widget/E2EBottomSheetDialog.kt index e94729e552..b79826678d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/widget/E2EBottomSheetDialog.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/widget/E2EBottomSheetDialog.kt @@ -47,10 +47,8 @@ abstract class E2EBottomSheetDialog(activity: Activity) : object : RecyclerView.OnScrollListener() { override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) { super.onScrollStateChanged(recyclerView, newState) - if ( - newState == RecyclerView.SCROLL_STATE_IDLE || - newState == RecyclerView.SCROLL_STATE_SETTLING - ) { + if (newState == RecyclerView.SCROLL_STATE_IDLE || + newState == RecyclerView.SCROLL_STATE_SETTLING) { sheetBehavior.isDraggable = true } else { sheetBehavior.isDraggable = !recyclerView.canScrollVertically(-1) diff --git a/app/src/main/java/eu/kanade/tachiyomi/widget/MaterialSpinnerView.kt b/app/src/main/java/eu/kanade/tachiyomi/widget/MaterialSpinnerView.kt index b332aa0741..bb859597f1 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/widget/MaterialSpinnerView.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/widget/MaterialSpinnerView.kt @@ -263,11 +263,9 @@ class MaterialSpinnerView constructor(context: Context, attrs: AttributeSet?) : private fun updateOriginalPositionMenu() { popup ?: return val originalPosition = originalPosition ?: return - if ( - originalPosition != selectedPosition && - originalPosition >= 0 && - originalPosition < (popup?.menu?.size() ?: 0) - ) { + if (originalPosition != selectedPosition && + originalPosition >= 0 && + originalPosition < (popup?.menu?.size() ?: 0)) { popup?.menu?.getItem(originalPosition)?.let { menuItem -> menuItem.icon = tintedOG() menuItem diff --git a/app/src/main/java/eu/kanade/tachiyomi/widget/TriStateCheckBox.kt b/app/src/main/java/eu/kanade/tachiyomi/widget/TriStateCheckBox.kt index 88c0041d48..33aa0c88ca 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/widget/TriStateCheckBox.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/widget/TriStateCheckBox.kt @@ -88,8 +88,7 @@ class TriStateCheckBox constructor(context: Context, attrs: AttributeSet?) : ColorStateList.valueOf( ColorUtils.setAlphaComponent( context.getResourceColor(R.attr.colorControlNormal), - (disabledAlpha * 255).roundToInt() - ), + (disabledAlpha * 255).roundToInt()), ) init { diff --git a/app/src/main/java/eu/kanade/tachiyomi/widget/materialdialogs/TriStateMultiChoiceDialogAdapter.kt b/app/src/main/java/eu/kanade/tachiyomi/widget/materialdialogs/TriStateMultiChoiceDialogAdapter.kt index 69a4a65731..78e9bf4294 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/widget/materialdialogs/TriStateMultiChoiceDialogAdapter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/widget/materialdialogs/TriStateMultiChoiceDialogAdapter.kt @@ -89,10 +89,7 @@ internal class TriStateMultiChoiceDialogAdapter( ): TriStateMultiChoiceViewHolder { val listItemView: View = ListitemTristatechoiceBinding.inflate( - LayoutInflater.from(dialog.context), - parent, - false - ) + LayoutInflater.from(dialog.context), parent, false) .root return TriStateMultiChoiceViewHolder( itemView = listItemView, diff --git a/app/src/main/java/eu/kanade/tachiyomi/widget/preference/KomgaLoginDialog.kt b/app/src/main/java/eu/kanade/tachiyomi/widget/preference/KomgaLoginDialog.kt index 9bf35ad0ac..48080a2d5b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/widget/preference/KomgaLoginDialog.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/widget/preference/KomgaLoginDialog.kt @@ -56,11 +56,9 @@ class KomgaLoginDialog(bundle: Bundle? = null) : startAnimation() } - if ( - binding.username.text.isNullOrBlank() || - binding.password.text.isNullOrBlank() || - binding.url.text.isNullOrBlank() - ) { + if (binding.username.text.isNullOrBlank() || + binding.password.text.isNullOrBlank() || + binding.url.text.isNullOrBlank()) { errorResult() context.toast(R.string.fields_cannot_be_blank) return diff --git a/app/src/main/java/eu/kanade/tachiyomi/widget/preference/MultiListMatPreference.kt b/app/src/main/java/eu/kanade/tachiyomi/widget/preference/MultiListMatPreference.kt index 79c6f41cb2..6bdf7fa5f6 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/widget/preference/MultiListMatPreference.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/widget/preference/MultiListMatPreference.kt @@ -100,8 +100,7 @@ constructor( var value = pos.mapNotNull { entryValues.getOrNull( - it - if (allSelectionRes != null && !showAllLast) 1 else 0 - ) + it - if (allSelectionRes != null && !showAllLast) 1 else 0) } .toSet() if (allSelectionRes != null && !allIsAlwaysSelected && selected[allPos]) diff --git a/app/src/main/java/org/nekomanga/App.kt b/app/src/main/java/org/nekomanga/App.kt index b45d10b0bd..db04094ed5 100644 --- a/app/src/main/java/org/nekomanga/App.kt +++ b/app/src/main/java/org/nekomanga/App.kt @@ -72,8 +72,7 @@ open class App : Application(), DefaultLifecycleObserver { Toast.makeText( applicationContext, "Error! App requires WebView to be installed", - Toast.LENGTH_LONG - ) + Toast.LENGTH_LONG) .show() } @@ -140,12 +139,10 @@ open class App : Application(), DefaultLifecycleObserver { ) setContentIntent(pendingIntent) } - if ( - ActivityCompat.checkSelfPermission( - this, - Manifest.permission.POST_NOTIFICATIONS, - ) != PackageManager.PERMISSION_GRANTED - ) { + if (ActivityCompat.checkSelfPermission( + this, + Manifest.permission.POST_NOTIFICATIONS, + ) != PackageManager.PERMISSION_GRANTED) { return@onEach } notificationManager.notify(Notifications.ID_INCOGNITO_MODE, notification) diff --git a/app/src/main/java/org/nekomanga/domain/details/MangaDetailsPreferences.kt b/app/src/main/java/org/nekomanga/domain/details/MangaDetailsPreferences.kt index 33558c49e0..215d8bec50 100644 --- a/app/src/main/java/org/nekomanga/domain/details/MangaDetailsPreferences.kt +++ b/app/src/main/java/org/nekomanga/domain/details/MangaDetailsPreferences.kt @@ -15,9 +15,7 @@ class MangaDetailsPreferences(private val preferenceStore: PreferenceStore) { fun sortChapterOrder() = this.preferenceStore.getInt( - "default_chapter_sort_by_source_or_number", - Manga.CHAPTER_SORTING_SOURCE - ) + "default_chapter_sort_by_source_or_number", Manga.CHAPTER_SORTING_SOURCE) fun hideChapterTitlesByDefault() = this.preferenceStore.getBoolean("hide_chapter_titles") diff --git a/app/src/main/java/org/nekomanga/domain/library/LibraryPreferences.kt b/app/src/main/java/org/nekomanga/domain/library/LibraryPreferences.kt index 12149e96e6..5b9256951b 100644 --- a/app/src/main/java/org/nekomanga/domain/library/LibraryPreferences.kt +++ b/app/src/main/java/org/nekomanga/domain/library/LibraryPreferences.kt @@ -44,9 +44,7 @@ class LibraryPreferences(private val preferenceStore: PreferenceStore) { fun layout() = this.preferenceStore.getInt( - "pref_display_library_layout", - LibraryItem.LAYOUT_COMFORTABLE_GRID - ) + "pref_display_library_layout", LibraryItem.LAYOUT_COMFORTABLE_GRID) fun sortingMode() = this.preferenceStore.getInt("library_sorting_mode") diff --git a/app/src/main/java/org/nekomanga/domain/reader/ReaderPreferences.kt b/app/src/main/java/org/nekomanga/domain/reader/ReaderPreferences.kt index ac83e94ab5..cec0682015 100644 --- a/app/src/main/java/org/nekomanga/domain/reader/ReaderPreferences.kt +++ b/app/src/main/java/org/nekomanga/domain/reader/ReaderPreferences.kt @@ -41,15 +41,11 @@ class ReaderPreferences(private val preferenceStore: PreferenceStore) { fun defaultReadingMode() = this.preferenceStore.getInt( - "pref_default_reading_mode_key", - ReadingModeType.RIGHT_TO_LEFT.flagValue - ) + "pref_default_reading_mode_key", ReadingModeType.RIGHT_TO_LEFT.flagValue) fun defaultOrientationType() = this.preferenceStore.getInt( - "pref_default_orientation_type_key", - OrientationType.FREE.flagValue - ) + "pref_default_orientation_type_key", OrientationType.FREE.flagValue) fun imageScaleType() = this.preferenceStore.getInt("pref_image_scale_type_key", 1) @@ -88,15 +84,11 @@ class ReaderPreferences(private val preferenceStore: PreferenceStore) { fun pagerNavInverted() = this.preferenceStore.getEnum( - "reader_tapping_inverted", - ViewerNavigation.TappingInvertMode.NONE - ) + "reader_tapping_inverted", ViewerNavigation.TappingInvertMode.NONE) fun webtoonNavInverted() = this.preferenceStore.getEnum( - "reader_tapping_inverted_webtoon", - ViewerNavigation.TappingInvertMode.NONE - ) + "reader_tapping_inverted_webtoon", ViewerNavigation.TappingInvertMode.NONE) fun pageLayout() = this.preferenceStore.getInt("page_layout", PageLayout.AUTOMATIC.value) @@ -109,17 +101,13 @@ class ReaderPreferences(private val preferenceStore: PreferenceStore) { fun webtoonReaderHideThreshold() = this.preferenceStore.getEnum( - "reader_hide_threshold", - PreferenceValues.ReaderHideThreshold.LOW - ) + "reader_hide_threshold", PreferenceValues.ReaderHideThreshold.LOW) fun webtoonInvertDoublePages() = this.preferenceStore.getBoolean("webtoon_invert_double_pages") fun readerBottomButtons() = this.preferenceStore.getStringSet( - "reader_bottom_buttons", - ReaderBottomButton.BUTTONS_DEFAULTS - ) + "reader_bottom_buttons", ReaderBottomButton.BUTTONS_DEFAULTS) fun preloadPageAmount() = this.preferenceStore.getInt("preload_size", 6) diff --git a/app/src/main/java/org/nekomanga/domain/track/store/DelayedTrackingStore.kt b/app/src/main/java/org/nekomanga/domain/track/store/DelayedTrackingStore.kt index 76ad119ecb..9e66365e21 100644 --- a/app/src/main/java/org/nekomanga/domain/track/store/DelayedTrackingStore.kt +++ b/app/src/main/java/org/nekomanga/domain/track/store/DelayedTrackingStore.kt @@ -22,9 +22,7 @@ class DelayedTrackingStore(context: Context) { fun getItems(): List { return preferences.all.mapNotNull { DelayedTrackingItem( - trackId = it.key.toLong(), - lastChapterRead = it.value.toString().toFloat() - ) + trackId = it.key.toLong(), lastChapterRead = it.value.toString().toFloat()) } } diff --git a/app/src/main/java/org/nekomanga/presentation/InfoScreen.kt b/app/src/main/java/org/nekomanga/presentation/InfoScreen.kt index 849b968228..c52883f3a5 100644 --- a/app/src/main/java/org/nekomanga/presentation/InfoScreen.kt +++ b/app/src/main/java/org/nekomanga/presentation/InfoScreen.kt @@ -131,14 +131,12 @@ fun InfoScreen( modifier = Modifier.fillMaxWidth(), text = headingText, style = MaterialTheme.typography.headlineLarge, - textAlign = TextAlign.Center - ) + textAlign = TextAlign.Center) Text( text = subtitleText, modifier = Modifier.padding(vertical = Size.small), style = MaterialTheme.typography.titleSmall, - textAlign = TextAlign.Center - ) + textAlign = TextAlign.Center) content() } diff --git a/app/src/main/java/org/nekomanga/presentation/components/AppBarActions.kt b/app/src/main/java/org/nekomanga/presentation/components/AppBarActions.kt index e7d4a2f0a1..13a86c44ad 100644 --- a/app/src/main/java/org/nekomanga/presentation/components/AppBarActions.kt +++ b/app/src/main/java/org/nekomanga/presentation/components/AppBarActions.kt @@ -31,15 +31,13 @@ fun listGridAppBarAction( title = UiText.StringResource(resourceId = R.string.display_as_grid), icon = Icons.Filled.ViewModule, onClick = onClick, - isEnabled = isEnabled - ) + isEnabled = isEnabled) false -> AppBar.Action( title = UiText.StringResource(resourceId = R.string.display_as_list), icon = Icons.Filled.ViewList, onClick = onClick, - isEnabled = isEnabled - ) + isEnabled = isEnabled) } } @@ -49,14 +47,12 @@ fun showLibraryEntriesAction(showEntries: Boolean, onClick: () -> Unit): AppBar. AppBar.Action( title = UiText.StringResource(R.string.hide_library_manga), icon = Icons.Filled.VisibilityOff, - onClick = onClick - ) + onClick = onClick) false -> AppBar.Action( title = UiText.StringResource(R.string.show_library_manga), icon = Icons.Filled.Visibility, - onClick = onClick - ) + onClick = onClick) } } diff --git a/app/src/main/java/org/nekomanga/presentation/components/ChapterRow.kt b/app/src/main/java/org/nekomanga/presentation/components/ChapterRow.kt index c8f78f8431..efd5dd78fc 100644 --- a/app/src/main/java/org/nekomanga/presentation/components/ChapterRow.kt +++ b/app/src/main/java/org/nekomanga/presentation/components/ChapterRow.kt @@ -110,9 +110,7 @@ fun ChapterRow( null -> MaterialTheme.colorScheme.surface else -> MaterialTheme.colorScheme.surfaceColorAtElevationCustomColor( - themeColor.buttonColor, - 8.dp - ) + themeColor.buttonColor, 8.dp) } when (dismissState.dismissDirection) { @@ -127,8 +125,7 @@ fun ChapterRow( Alignment.CenterEnd, color, stringResource(id = text), - themeColor.buttonColor - ) + themeColor.buttonColor) } DismissDirection.StartToEnd -> { val (icon, text) = @@ -141,8 +138,7 @@ fun ChapterRow( Alignment.CenterStart, color, stringResource(id = text), - themeColor.buttonColor - ) + themeColor.buttonColor) } else -> Unit } @@ -270,8 +266,7 @@ private fun ChapterInfo( false -> MaterialTheme.colorScheme.onSurface to MaterialTheme.colorScheme.onSurface.copy( - alpha = NekoColors.mediumAlphaLowContrast - ) + alpha = NekoColors.mediumAlphaLowContrast) } val rowColor = @@ -338,8 +333,7 @@ private fun ChapterInfo( MaterialTheme.typography.bodyLarge.copy( color = textColor, fontWeight = FontWeight.Medium, - letterSpacing = (-.6).sp - ), + letterSpacing = (-.6).sp), maxLines = 2, overflow = TextOverflow.Ellipsis, ) @@ -388,10 +382,7 @@ private fun ChapterInfo( rememberDrawablePainter( drawable = AppCompatResources.getDrawable( - LocalContext.current, - iconRes - ) - ) + LocalContext.current, iconRes)) Image( painter = painter, modifier = @@ -419,61 +410,65 @@ private fun ChapterInfo( } Box( modifier = Modifier.align(Alignment.CenterVertically), - contentAlignment = Alignment.Center - ) { - DownloadButton( - themeColorState.buttonColor, - downloadState, - downloadProgress, - Modifier.combinedClickable( - onClick = { - when (downloadState) { - Download.State.NOT_DOWNLOADED -> onDownload(DownloadAction.Download) - else -> chapterDropdown = true - } - }, - onLongClick = {}, - ), - ) + contentAlignment = Alignment.Center) { + DownloadButton( + themeColorState.buttonColor, + downloadState, + downloadProgress, + Modifier.combinedClickable( + onClick = { + when (downloadState) { + Download.State.NOT_DOWNLOADED -> onDownload(DownloadAction.Download) + else -> chapterDropdown = true + } + }, + onLongClick = {}, + ), + ) - val scope = rememberCoroutineScope() - SimpleDropdownMenu( - expanded = chapterDropdown, - themeColorState = themeColorState, - onDismiss = { chapterDropdown = false }, - dropDownItems = - when (downloadState) { - Download.State.DOWNLOADED -> { - persistentListOf( - SimpleDropDownItem.Action( - text = UiText.StringResource(R.string.remove), - onClick = { - scope.launchDelayed { onDownload(DownloadAction.Remove) } - }, - ), - ) - } - else -> { - persistentListOf( - SimpleDropDownItem.Action( - text = UiText.StringResource(R.string.start_downloading_now), - onClick = { - scope.launchDelayed { - onDownload(DownloadAction.ImmediateDownload) - } - }, - ), - SimpleDropDownItem.Action( - text = UiText.StringResource(R.string.cancel), - onClick = { - scope.launchDelayed { onDownload(DownloadAction.Cancel) } - }, - ), - ) - } - }, - ) - } + val scope = rememberCoroutineScope() + SimpleDropdownMenu( + expanded = chapterDropdown, + themeColorState = themeColorState, + onDismiss = { chapterDropdown = false }, + dropDownItems = + when (downloadState) { + Download.State.DOWNLOADED -> { + persistentListOf( + SimpleDropDownItem.Action( + text = UiText.StringResource(R.string.remove), + onClick = { + scope.launchDelayed { + onDownload(DownloadAction.Remove) + } + }, + ), + ) + } + else -> { + persistentListOf( + SimpleDropDownItem.Action( + text = + UiText.StringResource(R.string.start_downloading_now), + onClick = { + scope.launchDelayed { + onDownload(DownloadAction.ImmediateDownload) + } + }, + ), + SimpleDropDownItem.Action( + text = UiText.StringResource(R.string.cancel), + onClick = { + scope.launchDelayed { + onDownload(DownloadAction.Cancel) + } + }, + ), + ) + } + }, + ) + } } } diff --git a/app/src/main/java/org/nekomanga/presentation/components/Chip.kt b/app/src/main/java/org/nekomanga/presentation/components/Chip.kt index 118789945b..1bb229969d 100644 --- a/app/src/main/java/org/nekomanga/presentation/components/Chip.kt +++ b/app/src/main/java/org/nekomanga/presentation/components/Chip.kt @@ -35,8 +35,7 @@ fun Chip( .background(Color.Transparent), color = MaterialTheme.colorScheme.onSurfaceVariant.copy( - alpha = NekoColors.mediumAlphaHighContrast - ), + alpha = NekoColors.mediumAlphaHighContrast), ) } } diff --git a/app/src/main/java/org/nekomanga/presentation/components/ColumnFooter.kt b/app/src/main/java/org/nekomanga/presentation/components/ColumnFooter.kt index 3a8e185d20..6e497487c4 100644 --- a/app/src/main/java/org/nekomanga/presentation/components/ColumnFooter.kt +++ b/app/src/main/java/org/nekomanga/presentation/components/ColumnFooter.kt @@ -72,15 +72,13 @@ fun ColumnScope.SearchFooter( Icon( imageVector = Icons.Default.Warning, contentDescription = null, - tint = MaterialTheme.colorScheme.error - ) + tint = MaterialTheme.colorScheme.error) } else if (title.isNotEmpty()) { IconButton(onClick = { textChanged("") }) { Icon( imageVector = Icons.Default.Cancel, contentDescription = null, - tint = themeColorState.buttonColor - ) + tint = themeColorState.buttonColor) } } }, diff --git a/app/src/main/java/org/nekomanga/presentation/components/DownloadButton.kt b/app/src/main/java/org/nekomanga/presentation/components/DownloadButton.kt index 0f89bf0d00..a752d6ac4d 100644 --- a/app/src/main/java/org/nekomanga/presentation/components/DownloadButton.kt +++ b/app/src/main/java/org/nekomanga/presentation/components/DownloadButton.kt @@ -85,13 +85,11 @@ private fun NotDownloaded(buttonColor: Color, modifier: Modifier) { Background( color = Color.Transparent, borderStroke = BorderStroke(borderSize.dp, buttonColor), - modifier = modifier - ) { - DownloadIcon( - color = buttonColor, - icon = rememberVectorPainter(image = Icons.Filled.ArrowDownward) - ) - } + modifier = modifier) { + DownloadIcon( + color = buttonColor, + icon = rememberVectorPainter(image = Icons.Filled.ArrowDownward)) + } } @Composable @@ -129,9 +127,7 @@ private fun Queued(modifier: Modifier) { targetValue = finalState, animationSpec = infiniteRepeatable( - tween(1000, easing = EaseInOutCirc), - repeatMode = RepeatMode.Reverse - ), + tween(1000, easing = EaseInOutCirc), repeatMode = RepeatMode.Reverse), ) Background(color = Color.Transparent, modifier = modifier) { @@ -143,8 +139,7 @@ private fun Queued(modifier: Modifier) { DownloadIcon( color = disabledColor, icon = rememberVectorPainter(image = Icons.Filled.ArrowDownward), - alpha = alpha.value - ) + alpha = alpha.value) } } @@ -158,10 +153,8 @@ private fun Downloading(buttonColor: Color, modifier: Modifier, downloadProgress Triple( Color.Transparent, MaterialTheme.colorScheme.onSurface.copy( - alpha = NekoColors.disabledAlphaHighContrast - ), - buttonColor - ) + alpha = NekoColors.disabledAlphaHighContrast), + buttonColor) } val backgroundColor by @@ -171,8 +164,7 @@ private fun Downloading(buttonColor: Color, modifier: Modifier, downloadProgress animateFloatAsState( targetValue = (downloadProgress / Download.MaxProgress.toFloat()), animationSpec = ProgressIndicatorDefaults.ProgressAnimationSpec, - label = "downloadingProgress" - ) + label = "downloadingProgress") .value val iconPainter = rememberVectorPainter(image = Icons.Filled.ArrowDownward) @@ -186,11 +178,8 @@ private fun Downloading(buttonColor: Color, modifier: Modifier, downloadProgress targetValue = finalState, animationSpec = infiniteRepeatable( - tween(1000, easing = EaseInOutCirc), - repeatMode = RepeatMode.Reverse - ), - label = "downloadAlphaPulse" - ) + tween(1000, easing = EaseInOutCirc), repeatMode = RepeatMode.Reverse), + label = "downloadAlphaPulse") Background(color = backgroundColor, modifier = modifier) { CircularProgressIndicator( diff --git a/app/src/main/java/org/nekomanga/presentation/components/InLibrary.kt b/app/src/main/java/org/nekomanga/presentation/components/InLibrary.kt index 2731b7f73b..d6dff52509 100644 --- a/app/src/main/java/org/nekomanga/presentation/components/InLibrary.kt +++ b/app/src/main/java/org/nekomanga/presentation/components/InLibrary.kt @@ -50,12 +50,7 @@ internal fun InLibraryBadge(outline: Boolean, offset: Dp = (-2).dp) { Modifier.offset(x = offset, y = offset) .clip( RoundedCornerShape( - topStartPercent = 50, - 25, - bottomStartPercent = 25, - bottomEndPercent = 50 - ) - ) + topStartPercent = 50, 25, bottomStartPercent = 25, bottomEndPercent = 50)) .background(color = MaterialTheme.colorScheme.secondary) .conditional(outline) { this.border( @@ -66,17 +61,14 @@ internal fun InLibraryBadge(outline: Boolean, offset: Dp = (-2).dp) { topStartPercent = 50, 25, bottomStartPercent = 25, - bottomEndPercent = 50 - ) - ) + bottomEndPercent = 50)) }, ) { AutoSizeText( text = stringResource(id = R.string.in_library), style = MaterialTheme.typography.labelLarge.copy( - color = MaterialTheme.colorScheme.onSecondary - ), + color = MaterialTheme.colorScheme.onSecondary), modifier = Modifier.padding(horizontal = Size.tiny, vertical = Size.extraTiny), ) } diff --git a/app/src/main/java/org/nekomanga/presentation/components/LauncherIcon.kt b/app/src/main/java/org/nekomanga/presentation/components/LauncherIcon.kt index e620edcb34..c521a0a421 100644 --- a/app/src/main/java/org/nekomanga/presentation/components/LauncherIcon.kt +++ b/app/src/main/java/org/nekomanga/presentation/components/LauncherIcon.kt @@ -21,25 +21,18 @@ import org.nekomanga.R @Composable fun LauncherIcon(size: Dp) { ResourcesCompat.getDrawable( - LocalContext.current.resources, - R.mipmap.ic_launcher, - LocalContext.current.theme - ) + LocalContext.current.resources, R.mipmap.ic_launcher, LocalContext.current.theme) ?.let { drawable -> val bitmap = Bitmap.createBitmap( - drawable.intrinsicWidth, - drawable.intrinsicHeight, - Bitmap.Config.ARGB_8888 - ) + drawable.intrinsicWidth, drawable.intrinsicHeight, Bitmap.Config.ARGB_8888) val canvas = android.graphics.Canvas(bitmap) drawable.setBounds(0, 0, canvas.width, canvas.height) drawable.draw(canvas) Image( bitmap = bitmap.asImageBitmap(), contentDescription = null, - modifier = Modifier.requiredSize(size) - ) + modifier = Modifier.requiredSize(size)) } } diff --git a/app/src/main/java/org/nekomanga/presentation/components/MangaCover.kt b/app/src/main/java/org/nekomanga/presentation/components/MangaCover.kt index c0482a722c..ee18d25a9b 100644 --- a/app/src/main/java/org/nekomanga/presentation/components/MangaCover.kt +++ b/app/src/main/java/org/nekomanga/presentation/components/MangaCover.kt @@ -50,8 +50,7 @@ enum class MangaCover(val ratio: Float) { this.border( width = Outline.thickness, color = Outline.color, - shape = RoundedCornerShape(Shapes.coverRadius) - ) + shape = RoundedCornerShape(Shapes.coverRadius)) }, ) } diff --git a/app/src/main/java/org/nekomanga/presentation/components/MangaGridView.kt b/app/src/main/java/org/nekomanga/presentation/components/MangaGridView.kt index 9b68770f2d..a9681e5a9b 100644 --- a/app/src/main/java/org/nekomanga/presentation/components/MangaGridView.kt +++ b/app/src/main/java/org/nekomanga/presentation/components/MangaGridView.kt @@ -206,8 +206,7 @@ fun BoxScope.CompactGridItem( listOf( Color.Transparent, Color.Black.copy(NekoColors.veryLowContrast), - Color.Black.copy(NekoColors.highAlphaLowContrast) - ), + Color.Black.copy(NekoColors.highAlphaLowContrast)), ), shape = RoundedCornerShape( diff --git a/app/src/main/java/org/nekomanga/presentation/components/MangaListView.kt b/app/src/main/java/org/nekomanga/presentation/components/MangaListView.kt index 04cb84ed9f..31a79fbd06 100644 --- a/app/src/main/java/org/nekomanga/presentation/components/MangaListView.kt +++ b/app/src/main/java/org/nekomanga/presentation/components/MangaListView.kt @@ -87,20 +87,19 @@ fun MangaListWithHeader( mangaList, key = { _, displayManga -> Objects.hash(displayManga.title, displayManga.mangaId, stringRes) + }) { _, displayManga -> + MangaRow( + displayManga = displayManga, + shouldOutlineCover, + modifier = + Modifier.fillMaxWidth() + .wrapContentHeight() + .combinedClickable( + onClick = { onClick(displayManga.mangaId) }, + onLongClick = { onLongClick(displayManga) }, + ), + ) } - ) { _, displayManga -> - MangaRow( - displayManga = displayManga, - shouldOutlineCover, - modifier = - Modifier.fillMaxWidth() - .wrapContentHeight() - .combinedClickable( - onClick = { onClick(displayManga.mangaId) }, - onLongClick = { onLongClick(displayManga) }, - ), - ) - } } } } @@ -125,9 +124,7 @@ private fun MangaRow( MangaListTitle(title = displayManga.title, maxLines = titleLineCount) MangaListSubtitle( - text = displayManga.displayText, - textRes = displayManga.displayTextRes - ) + text = displayManga.displayText, textRes = displayManga.displayTextRes) } } } diff --git a/app/src/main/java/org/nekomanga/presentation/components/NavBarPadding.kt b/app/src/main/java/org/nekomanga/presentation/components/NavBarPadding.kt index 1f51885a23..0927b56ef9 100644 --- a/app/src/main/java/org/nekomanga/presentation/components/NavBarPadding.kt +++ b/app/src/main/java/org/nekomanga/presentation/components/NavBarPadding.kt @@ -49,15 +49,12 @@ fun rememberNavBarPadding( val sideNav = PaddingValues( start = Size.navBarSize, - bottom = WindowInsets.navigationBars.asPaddingValues().calculateBottomPadding() - ) + bottom = WindowInsets.navigationBars.asPaddingValues().calculateBottomPadding()) return remember( - isSideBarShowing, - WindowInsets.navigationBars.asPaddingValues().calculateBottomPadding() - ) { - when (isSideBarShowing) { - true -> sideNav - false -> bottomNav + isSideBarShowing, WindowInsets.navigationBars.asPaddingValues().calculateBottomPadding()) { + when (isSideBarShowing) { + true -> sideNav + false -> bottomNav + } } - } } diff --git a/app/src/main/java/org/nekomanga/presentation/components/NekoScaffold.kt b/app/src/main/java/org/nekomanga/presentation/components/NekoScaffold.kt index 67d0ff80b6..a38adc26f8 100644 --- a/app/src/main/java/org/nekomanga/presentation/components/NekoScaffold.kt +++ b/app/src/main/java/org/nekomanga/presentation/components/NekoScaffold.kt @@ -105,8 +105,7 @@ fun NekoScaffold( actions, incognitoMode, isRoot, - scrollBehavior - ) + scrollBehavior) NekoScaffoldType.NoTitle -> NoTitleTopAppBar( color, @@ -114,8 +113,7 @@ fun NekoScaffold( navigationIcon, onNavigationIconClicked, actions, - scrollBehavior - ) + scrollBehavior) NekoScaffoldType.TitleAndSubtitle -> TitleAndSubtitleTopAppBar( color, @@ -125,8 +123,7 @@ fun NekoScaffold( navigationIcon, onNavigationIconClicked, actions, - scrollBehavior - ) + scrollBehavior) NekoScaffoldType.Search -> NoTitleSearchTopAppBar( onSearch, @@ -136,8 +133,7 @@ fun NekoScaffold( navigationIcon, onNavigationIconClicked, actions, - scrollBehavior - ) + scrollBehavior) } } }, @@ -255,68 +251,69 @@ private fun NoTitleSearchTopAppBar( AnimatedVisibility( visible = showTextField, enter = fadeIn() + slideInVertically(), - exit = fadeOut() + slideOutVertically() - ) { - // research on configuration change + exit = fadeOut() + slideOutVertically()) { + // research on configuration change - OutlinedTextField( - modifier = - Modifier.weight(1f) - .padding(top = Size.small, bottom = Size.small, start = Size.extraLarge) - .focusRequester(focusRequester), - value = searchText, - placeholder = { Text(text = stringResource(id = R.string.search_chapters)) }, - onValueChange = { - searchText = it - onSearchText(it) - }, - colors = - TextFieldDefaults.colors( - focusedContainerColor = Color.Transparent, - unfocusedContainerColor = Color.Transparent, - disabledContainerColor = Color.Transparent, - cursorColor = - LocalContentColor.current.copy(alpha = LocalContentAlpha.current), - focusedIndicatorColor = Color.Transparent, - unfocusedIndicatorColor = Color.Transparent, - ), - trailingIcon = { - AnimatedVisibility( - visible = searchText.isNotBlank(), - enter = fadeIn(), - exit = fadeOut() - ) { - ToolTipButton( - toolTipLabel = stringResource(id = R.string.clear), - icon = Icons.Filled.Close, - buttonClicked = { - onSearchText("") - searchText = "" - }, - ) + OutlinedTextField( + modifier = + Modifier.weight(1f) + .padding( + top = Size.small, bottom = Size.small, start = Size.extraLarge) + .focusRequester(focusRequester), + value = searchText, + placeholder = { + Text(text = stringResource(id = R.string.search_chapters)) + }, + onValueChange = { + searchText = it + onSearchText(it) + }, + colors = + TextFieldDefaults.colors( + focusedContainerColor = Color.Transparent, + unfocusedContainerColor = Color.Transparent, + disabledContainerColor = Color.Transparent, + cursorColor = + LocalContentColor.current.copy( + alpha = LocalContentAlpha.current), + focusedIndicatorColor = Color.Transparent, + unfocusedIndicatorColor = Color.Transparent, + ), + trailingIcon = { + AnimatedVisibility( + visible = searchText.isNotBlank(), + enter = fadeIn(), + exit = fadeOut()) { + ToolTipButton( + toolTipLabel = stringResource(id = R.string.clear), + icon = Icons.Filled.Close, + buttonClicked = { + onSearchText("") + searchText = "" + }, + ) + } + }, + maxLines = 1, + singleLine = true, + keyboardOptions = + KeyboardOptions.Default.copy( + imeAction = androidx.compose.ui.text.input.ImeAction.Search), + keyboardActions = + KeyboardActions( + onSearch = { onSearchText(searchText) }, + ), + ) + LaunchedEffect(Unit) { + if (!alreadyRequestedFocus) { + focusRequester.requestFocus() + alreadyRequestedFocus = true + } + if (searchText.isNotBlank()) { + onSearchText(searchText) } - }, - maxLines = 1, - singleLine = true, - keyboardOptions = - KeyboardOptions.Default.copy( - imeAction = androidx.compose.ui.text.input.ImeAction.Search - ), - keyboardActions = - KeyboardActions( - onSearch = { onSearchText(searchText) }, - ), - ) - LaunchedEffect(Unit) { - if (!alreadyRequestedFocus) { - focusRequester.requestFocus() - alreadyRequestedFocus = true - } - if (searchText.isNotBlank()) { - onSearchText(searchText) } } - } val icon = when (showTextField) { true -> Icons.Filled.SearchOff @@ -365,8 +362,7 @@ private fun TitleOnlyTopAppBar( title = { AutoSizeText( text = title, - style = MaterialTheme.typography.titleLarge.copy(letterSpacing = (-.6).sp) - ) + style = MaterialTheme.typography.titleLarge.copy(letterSpacing = (-.6).sp)) }, navigationIcon = { if (incognitoMode) { diff --git a/app/src/main/java/org/nekomanga/presentation/components/OtherResultListView.kt b/app/src/main/java/org/nekomanga/presentation/components/OtherResultListView.kt index b3f753a86d..a75ab13e2b 100644 --- a/app/src/main/java/org/nekomanga/presentation/components/OtherResultListView.kt +++ b/app/src/main/java/org/nekomanga/presentation/components/OtherResultListView.kt @@ -67,8 +67,7 @@ private fun ResultRow( style = MaterialTheme.typography.bodyMedium, color = MaterialTheme.colorScheme.onSurface.copy( - alpha = NekoColors.mediumAlphaLowContrast - ), + alpha = NekoColors.mediumAlphaLowContrast), maxLines = 4, overflow = TextOverflow.Ellipsis, ) diff --git a/app/src/main/java/org/nekomanga/presentation/components/SheetHandle.kt b/app/src/main/java/org/nekomanga/presentation/components/SheetHandle.kt index ca94441185..806a5a861e 100644 --- a/app/src/main/java/org/nekomanga/presentation/components/SheetHandle.kt +++ b/app/src/main/java/org/nekomanga/presentation/components/SheetHandle.kt @@ -24,10 +24,8 @@ fun ColumnScope.sheetHandle() { .background( color = MaterialTheme.colorScheme.onSurface.copy( - alpha = NekoColors.disabledAlphaLowContrast - ), - CircleShape - ) + alpha = NekoColors.disabledAlphaLowContrast), + CircleShape) .align(Alignment.CenterHorizontally), ) } diff --git a/app/src/main/java/org/nekomanga/presentation/components/SortRow.kt b/app/src/main/java/org/nekomanga/presentation/components/SortRow.kt index 38652bf38d..70c12e8b73 100644 --- a/app/src/main/java/org/nekomanga/presentation/components/SortRow.kt +++ b/app/src/main/java/org/nekomanga/presentation/components/SortRow.kt @@ -55,16 +55,14 @@ fun SortRow( imageVector = Icons.Filled.ArrowUpward, contentDescription = null, tint = tintColor, - modifier = Modifier.size(24.dp) - ) + modifier = Modifier.size(24.dp)) } MangaConstants.SortState.Descending -> { Icon( imageVector = Icons.Filled.ArrowDownward, contentDescription = null, tint = tintColor, - modifier = Modifier.size(24.dp) - ) + modifier = Modifier.size(24.dp)) } MangaConstants.SortState.None -> { Gap(24.dp) diff --git a/app/src/main/java/org/nekomanga/presentation/components/ToolTipComponents.kt b/app/src/main/java/org/nekomanga/presentation/components/ToolTipComponents.kt index f5afb5a39e..9e37a8b58e 100644 --- a/app/src/main/java/org/nekomanga/presentation/components/ToolTipComponents.kt +++ b/app/src/main/java/org/nekomanga/presentation/components/ToolTipComponents.kt @@ -61,8 +61,7 @@ fun ToolTipButton( Text( modifier = Modifier.padding(Size.tiny), style = MaterialTheme.typography.bodyLarge, - text = toolTipLabel - ) + text = toolTipLabel) } }, ) { @@ -117,8 +116,7 @@ fun CombinedClickableIconButton( enabledTint } else { MaterialTheme.colorScheme.onSurface.copy( - alpha = NekoColors.disabledAlphaLowContrast - ) + alpha = NekoColors.disabledAlphaLowContrast) } CompositionLocalProvider(LocalContentColor provides contentColor, content = content) } diff --git a/app/src/main/java/org/nekomanga/presentation/components/TriStateComponents.kt b/app/src/main/java/org/nekomanga/presentation/components/TriStateComponents.kt index cb7e9ed053..caccc224b1 100644 --- a/app/src/main/java/org/nekomanga/presentation/components/TriStateComponents.kt +++ b/app/src/main/java/org/nekomanga/presentation/components/TriStateComponents.kt @@ -55,8 +55,7 @@ fun TriStateCheckboxRow( color = if (!disabled) MaterialTheme.colorScheme.onSurface else MaterialTheme.colorScheme.onSurface.copy(NekoColors.disabledAlphaLowContrast), - style = rowTextStyle - ) + style = rowTextStyle) } } diff --git a/app/src/main/java/org/nekomanga/presentation/components/dialog/AddCategoryDialog.kt b/app/src/main/java/org/nekomanga/presentation/components/dialog/AddCategoryDialog.kt index 0f2379e2f7..70ca204ccf 100644 --- a/app/src/main/java/org/nekomanga/presentation/components/dialog/AddCategoryDialog.kt +++ b/app/src/main/java/org/nekomanga/presentation/components/dialog/AddCategoryDialog.kt @@ -40,71 +40,69 @@ fun AddCategoryDialog( CompositionLocalProvider( LocalRippleTheme provides themeColorState.rippleTheme, - LocalTextSelectionColors provides themeColorState.textSelectionColors - ) { - LaunchedEffect(categoryText, currentCategories) { - if (categoryText.isEmpty()) { - saveEnabled = false - errorMessage = "" - } else if (currentCategories.any { it.name.equals(categoryText, true) }) { - saveEnabled = false - errorMessage = context.getString(R.string.category_with_name_exists) - } else { - saveEnabled = true - errorMessage = "" + LocalTextSelectionColors provides themeColorState.textSelectionColors) { + LaunchedEffect(categoryText, currentCategories) { + if (categoryText.isEmpty()) { + saveEnabled = false + errorMessage = "" + } else if (currentCategories.any { it.name.equals(categoryText, true) }) { + saveEnabled = false + errorMessage = context.getString(R.string.category_with_name_exists) + } else { + saveEnabled = true + errorMessage = "" + } } - } - AlertDialog( - title = { Text(text = stringResource(id = R.string.new_category)) }, - text = { - Column { - OutlinedTextField( - value = categoryText, - onValueChange = { categoryText = it }, - label = { Text(text = stringResource(id = R.string.category)) }, - singleLine = true, - maxLines = 1, + AlertDialog( + title = { Text(text = stringResource(id = R.string.new_category)) }, + text = { + Column { + OutlinedTextField( + value = categoryText, + onValueChange = { categoryText = it }, + label = { Text(text = stringResource(id = R.string.category)) }, + singleLine = true, + maxLines = 1, + colors = + TextFieldDefaults.outlinedTextFieldColors( + cursorColor = themeColorState.buttonColor, + focusedLabelColor = themeColorState.buttonColor, + focusedBorderColor = themeColorState.buttonColor, + ), + ) + Gap(Size.extraTiny) + Text( + text = errorMessage, + style = + MaterialTheme.typography.labelSmall.copy( + color = MaterialTheme.colorScheme.error)) + } + }, + onDismissRequest = onDismiss, + confirmButton = { + TextButton( + onClick = { + onConfirm(categoryText) + onDismiss() + }, + enabled = saveEnabled, colors = - TextFieldDefaults.outlinedTextFieldColors( - cursorColor = themeColorState.buttonColor, - focusedLabelColor = themeColorState.buttonColor, - focusedBorderColor = themeColorState.buttonColor, - ), - ) - Gap(Size.extraTiny) - Text( - text = errorMessage, - style = - MaterialTheme.typography.labelSmall.copy( - color = MaterialTheme.colorScheme.error - ) - ) - } - }, - onDismissRequest = onDismiss, - confirmButton = { - TextButton( - onClick = { - onConfirm(categoryText) - onDismiss() - }, - enabled = saveEnabled, - colors = - ButtonDefaults.textButtonColors(contentColor = themeColorState.buttonColor), - ) { - Text(text = stringResource(id = R.string.save)) - } - }, - dismissButton = { - TextButton( - onClick = onDismiss, - colors = - ButtonDefaults.textButtonColors(contentColor = themeColorState.buttonColor) - ) { - Text(text = stringResource(id = R.string.cancel)) - } - }, - ) - } + ButtonDefaults.textButtonColors( + contentColor = themeColorState.buttonColor), + ) { + Text(text = stringResource(id = R.string.save)) + } + }, + dismissButton = { + TextButton( + onClick = onDismiss, + colors = + ButtonDefaults.textButtonColors( + contentColor = themeColorState.buttonColor)) { + Text(text = stringResource(id = R.string.cancel)) + } + }, + ) + } } diff --git a/app/src/main/java/org/nekomanga/presentation/components/dialog/RemoveTrackingDialog.kt b/app/src/main/java/org/nekomanga/presentation/components/dialog/RemoveTrackingDialog.kt index b17c4aa11a..ab81ceee11 100644 --- a/app/src/main/java/org/nekomanga/presentation/components/dialog/RemoveTrackingDialog.kt +++ b/app/src/main/java/org/nekomanga/presentation/components/dialog/RemoveTrackingDialog.kt @@ -30,47 +30,47 @@ fun RemoveTrackingDialog( ) { CompositionLocalProvider( LocalRippleTheme provides themeColorState.rippleTheme, - LocalTextSelectionColors provides themeColorState.textSelectionColors - ) { - var removeFromTracker by remember { mutableStateOf(true) } + LocalTextSelectionColors provides themeColorState.textSelectionColors) { + var removeFromTracker by remember { mutableStateOf(true) } - AlertDialog( - title = { Text(text = stringResource(id = R.string.remove_tracking)) }, - text = { - if (canRemoveFromTracker) { - Column { - CheckboxRow( - modifier = Modifier.fillMaxWidth(), - checkedState = removeFromTracker, - checkedChange = { removeFromTracker = !removeFromTracker }, - themeColorState = themeColorState, - rowText = stringResource(id = R.string.remove_tracking_from_, name), - ) + AlertDialog( + title = { Text(text = stringResource(id = R.string.remove_tracking)) }, + text = { + if (canRemoveFromTracker) { + Column { + CheckboxRow( + modifier = Modifier.fillMaxWidth(), + checkedState = removeFromTracker, + checkedChange = { removeFromTracker = !removeFromTracker }, + themeColorState = themeColorState, + rowText = stringResource(id = R.string.remove_tracking_from_, name), + ) + } } - } - }, - onDismissRequest = onDismiss, - confirmButton = { - TextButton( - onClick = { - onConfirm(removeFromTracker && canRemoveFromTracker) - onDismiss() - }, - colors = - ButtonDefaults.textButtonColors(contentColor = themeColorState.buttonColor), - ) { - Text(text = stringResource(id = R.string.remove)) - } - }, - dismissButton = { - TextButton( - onClick = onDismiss, - colors = - ButtonDefaults.textButtonColors(contentColor = themeColorState.buttonColor) - ) { - Text(text = stringResource(id = R.string.cancel)) - } - }, - ) - } + }, + onDismissRequest = onDismiss, + confirmButton = { + TextButton( + onClick = { + onConfirm(removeFromTracker && canRemoveFromTracker) + onDismiss() + }, + colors = + ButtonDefaults.textButtonColors( + contentColor = themeColorState.buttonColor), + ) { + Text(text = stringResource(id = R.string.remove)) + } + }, + dismissButton = { + TextButton( + onClick = onDismiss, + colors = + ButtonDefaults.textButtonColors( + contentColor = themeColorState.buttonColor)) { + Text(text = stringResource(id = R.string.cancel)) + } + }, + ) + } } diff --git a/app/src/main/java/org/nekomanga/presentation/components/dialog/RemovedChaptersDialog.kt b/app/src/main/java/org/nekomanga/presentation/components/dialog/RemovedChaptersDialog.kt index 5751d256fd..e65a401229 100644 --- a/app/src/main/java/org/nekomanga/presentation/components/dialog/RemovedChaptersDialog.kt +++ b/app/src/main/java/org/nekomanga/presentation/components/dialog/RemovedChaptersDialog.kt @@ -24,55 +24,55 @@ fun RemovedChaptersDialog( ) { CompositionLocalProvider( LocalRippleTheme provides themeColorState.rippleTheme, - LocalTextSelectionColors provides themeColorState.textSelectionColors - ) { - val context = LocalContext.current + LocalTextSelectionColors provides themeColorState.textSelectionColors) { + val context = LocalContext.current - AlertDialog( - title = { Text(text = stringResource(id = R.string.delete_removed_chapters)) }, - text = { - val chapterNames = chapters.map { it.chapter.name } - Text( - text = - context.resources.getQuantityString( - R.plurals.deleted_chapters, - chapters.size, - chapters.size, - if (chapters.size > 5) { - "${chapterNames.take(5 - 1).joinToString(", ")}, " + - context.resources.getQuantityString( - R.plurals.notification_and_n_more, - (chapterNames.size - (4 - 1)), - (chapterNames.size - (4 - 1)), - ) - } else { - chapterNames.joinToString(", ") - }, - ), - ) - }, - onDismissRequest = onDismiss, - confirmButton = { - TextButton( - onClick = { - onConfirm() - onDismiss() - }, - colors = - ButtonDefaults.textButtonColors(contentColor = themeColorState.buttonColor), - ) { - Text(text = stringResource(id = R.string.delete)) - } - }, - dismissButton = { - TextButton( - onClick = onDismiss, - colors = - ButtonDefaults.textButtonColors(contentColor = themeColorState.buttonColor) - ) { - Text(text = stringResource(id = R.string.keep)) - } - }, - ) - } + AlertDialog( + title = { Text(text = stringResource(id = R.string.delete_removed_chapters)) }, + text = { + val chapterNames = chapters.map { it.chapter.name } + Text( + text = + context.resources.getQuantityString( + R.plurals.deleted_chapters, + chapters.size, + chapters.size, + if (chapters.size > 5) { + "${chapterNames.take(5 - 1).joinToString(", ")}, " + + context.resources.getQuantityString( + R.plurals.notification_and_n_more, + (chapterNames.size - (4 - 1)), + (chapterNames.size - (4 - 1)), + ) + } else { + chapterNames.joinToString(", ") + }, + ), + ) + }, + onDismissRequest = onDismiss, + confirmButton = { + TextButton( + onClick = { + onConfirm() + onDismiss() + }, + colors = + ButtonDefaults.textButtonColors( + contentColor = themeColorState.buttonColor), + ) { + Text(text = stringResource(id = R.string.delete)) + } + }, + dismissButton = { + TextButton( + onClick = onDismiss, + colors = + ButtonDefaults.textButtonColors( + contentColor = themeColorState.buttonColor)) { + Text(text = stringResource(id = R.string.keep)) + } + }, + ) + } } diff --git a/app/src/main/java/org/nekomanga/presentation/components/dialog/SaveFilterDialog.kt b/app/src/main/java/org/nekomanga/presentation/components/dialog/SaveFilterDialog.kt index 316c1c1697..dfd966e31d 100644 --- a/app/src/main/java/org/nekomanga/presentation/components/dialog/SaveFilterDialog.kt +++ b/app/src/main/java/org/nekomanga/presentation/components/dialog/SaveFilterDialog.kt @@ -40,71 +40,69 @@ fun SaveFilterDialog( CompositionLocalProvider( LocalRippleTheme provides themeColorState.rippleTheme, - LocalTextSelectionColors provides themeColorState.textSelectionColors - ) { - LaunchedEffect(saveFilterText, currentSavedFilters) { - if (saveFilterText.isEmpty()) { - saveEnabled = false - errorMessage = "" - } else if (currentSavedFilters.any { it.name.equals(saveFilterText, true) }) { - saveEnabled = false - errorMessage = context.getString(R.string.filter_with_name_exists) - } else { - saveEnabled = true - errorMessage = "" + LocalTextSelectionColors provides themeColorState.textSelectionColors) { + LaunchedEffect(saveFilterText, currentSavedFilters) { + if (saveFilterText.isEmpty()) { + saveEnabled = false + errorMessage = "" + } else if (currentSavedFilters.any { it.name.equals(saveFilterText, true) }) { + saveEnabled = false + errorMessage = context.getString(R.string.filter_with_name_exists) + } else { + saveEnabled = true + errorMessage = "" + } } - } - AlertDialog( - title = { Text(text = stringResource(id = R.string.save_filter)) }, - text = { - Column { - OutlinedTextField( - value = saveFilterText, - onValueChange = { saveFilterText = it }, - label = { Text(text = stringResource(id = R.string.name)) }, - singleLine = true, - maxLines = 1, + AlertDialog( + title = { Text(text = stringResource(id = R.string.save_filter)) }, + text = { + Column { + OutlinedTextField( + value = saveFilterText, + onValueChange = { saveFilterText = it }, + label = { Text(text = stringResource(id = R.string.name)) }, + singleLine = true, + maxLines = 1, + colors = + TextFieldDefaults.outlinedTextFieldColors( + cursorColor = themeColorState.buttonColor, + focusedLabelColor = themeColorState.buttonColor, + focusedBorderColor = themeColorState.buttonColor, + ), + ) + Gap(Size.extraTiny) + Text( + text = errorMessage, + style = + MaterialTheme.typography.labelSmall.copy( + color = MaterialTheme.colorScheme.error)) + } + }, + onDismissRequest = onDismiss, + confirmButton = { + TextButton( + onClick = { + onConfirm(saveFilterText) + onDismiss() + }, + enabled = saveEnabled, colors = - TextFieldDefaults.outlinedTextFieldColors( - cursorColor = themeColorState.buttonColor, - focusedLabelColor = themeColorState.buttonColor, - focusedBorderColor = themeColorState.buttonColor, - ), - ) - Gap(Size.extraTiny) - Text( - text = errorMessage, - style = - MaterialTheme.typography.labelSmall.copy( - color = MaterialTheme.colorScheme.error - ) - ) - } - }, - onDismissRequest = onDismiss, - confirmButton = { - TextButton( - onClick = { - onConfirm(saveFilterText) - onDismiss() - }, - enabled = saveEnabled, - colors = - ButtonDefaults.textButtonColors(contentColor = themeColorState.buttonColor), - ) { - Text(text = stringResource(id = R.string.save)) - } - }, - dismissButton = { - TextButton( - onClick = onDismiss, - colors = - ButtonDefaults.textButtonColors(contentColor = themeColorState.buttonColor) - ) { - Text(text = stringResource(id = R.string.cancel)) - } - }, - ) - } + ButtonDefaults.textButtonColors( + contentColor = themeColorState.buttonColor), + ) { + Text(text = stringResource(id = R.string.save)) + } + }, + dismissButton = { + TextButton( + onClick = onDismiss, + colors = + ButtonDefaults.textButtonColors( + contentColor = themeColorState.buttonColor)) { + Text(text = stringResource(id = R.string.cancel)) + } + }, + ) + } } diff --git a/app/src/main/java/org/nekomanga/presentation/components/dialog/TrackingChapterDialog.kt b/app/src/main/java/org/nekomanga/presentation/components/dialog/TrackingChapterDialog.kt index 45e8bacbd6..22e156abcb 100644 --- a/app/src/main/java/org/nekomanga/presentation/components/dialog/TrackingChapterDialog.kt +++ b/app/src/main/java/org/nekomanga/presentation/components/dialog/TrackingChapterDialog.kt @@ -35,64 +35,62 @@ fun TrackingChapterDialog( ) { CompositionLocalProvider( LocalRippleTheme provides themeColorState.rippleTheme, - LocalTextSelectionColors provides themeColorState.textSelectionColors - ) { - var currentChapter by remember { mutableStateOf(track.lastChapterRead.toInt()) } + LocalTextSelectionColors provides themeColorState.textSelectionColors) { + var currentChapter by remember { mutableStateOf(track.lastChapterRead.toInt()) } - val range = - when (track.totalChapters > 0) { - true -> track.totalChapters - false -> 10000 - } - - AlertDialog( - title = { - Text( - text = stringResource(id = R.string.chapters), - textAlign = TextAlign.Center, - modifier = Modifier.fillMaxWidth() - ) - }, - text = { - Box( - contentAlignment = Alignment.Center, - modifier = Modifier.padding(16.dp).fillMaxWidth(), - ) { - NumberPicker( - modifier = Modifier.fillMaxWidth(.4f), - value = currentChapter, - onValueChange = { newChapter -> currentChapter = newChapter }, - range = 0..range, - textStyle = - MaterialTheme.typography.titleMedium.copy( - color = MaterialTheme.colorScheme.onSurface - ), - dividersColor = themeColorState.buttonColor, - ) - } - }, - onDismissRequest = onDismiss, - dismissButton = { - TextButton( - onClick = onDismiss, - colors = - ButtonDefaults.textButtonColors(contentColor = themeColorState.buttonColor) - ) { - Text(text = stringResource(id = R.string.cancel)) + val range = + when (track.totalChapters > 0) { + true -> track.totalChapters + false -> 10000 } - }, - confirmButton = { - TextButton( - onClick = { - trackChapterChanged(currentChapter) - onDismiss() - }, - colors = - ButtonDefaults.textButtonColors(contentColor = themeColorState.buttonColor), - ) { - Text(text = stringResource(id = android.R.string.ok)) - } - }, - ) - } + + AlertDialog( + title = { + Text( + text = stringResource(id = R.string.chapters), + textAlign = TextAlign.Center, + modifier = Modifier.fillMaxWidth()) + }, + text = { + Box( + contentAlignment = Alignment.Center, + modifier = Modifier.padding(16.dp).fillMaxWidth(), + ) { + NumberPicker( + modifier = Modifier.fillMaxWidth(.4f), + value = currentChapter, + onValueChange = { newChapter -> currentChapter = newChapter }, + range = 0..range, + textStyle = + MaterialTheme.typography.titleMedium.copy( + color = MaterialTheme.colorScheme.onSurface), + dividersColor = themeColorState.buttonColor, + ) + } + }, + onDismissRequest = onDismiss, + dismissButton = { + TextButton( + onClick = onDismiss, + colors = + ButtonDefaults.textButtonColors( + contentColor = themeColorState.buttonColor)) { + Text(text = stringResource(id = R.string.cancel)) + } + }, + confirmButton = { + TextButton( + onClick = { + trackChapterChanged(currentChapter) + onDismiss() + }, + colors = + ButtonDefaults.textButtonColors( + contentColor = themeColorState.buttonColor), + ) { + Text(text = stringResource(id = android.R.string.ok)) + } + }, + ) + } } diff --git a/app/src/main/java/org/nekomanga/presentation/components/dialog/TrackingScoreDialog.kt b/app/src/main/java/org/nekomanga/presentation/components/dialog/TrackingScoreDialog.kt index 95446d1364..0b805407eb 100644 --- a/app/src/main/java/org/nekomanga/presentation/components/dialog/TrackingScoreDialog.kt +++ b/app/src/main/java/org/nekomanga/presentation/components/dialog/TrackingScoreDialog.kt @@ -35,69 +35,67 @@ fun TrackingScoreDialog( ) { CompositionLocalProvider( LocalRippleTheme provides themeColorState.rippleTheme, - LocalTextSelectionColors provides themeColorState.textSelectionColors - ) { - val displayedScore = trackAndService.service.displayScore(trackAndService.track) - val index = - when { - displayedScore == "-" -> 0 - trackAndService.service.scoreList.indexOf(displayedScore) != -1 -> - trackAndService.service.scoreList.indexOf(displayedScore) - else -> 0 - } + LocalTextSelectionColors provides themeColorState.textSelectionColors) { + val displayedScore = trackAndService.service.displayScore(trackAndService.track) + val index = + when { + displayedScore == "-" -> 0 + trackAndService.service.scoreList.indexOf(displayedScore) != -1 -> + trackAndService.service.scoreList.indexOf(displayedScore) + else -> 0 + } - var currentIndex by remember { mutableStateOf(index) } + var currentIndex by remember { mutableStateOf(index) } - AlertDialog( - title = { - Text( - text = stringResource(id = R.string.score), - textAlign = TextAlign.Center, - modifier = Modifier.fillMaxWidth() - ) - }, - text = { - Box( - contentAlignment = Alignment.Center, - modifier = Modifier.padding(16.dp).fillMaxWidth(), - ) { - ListItemPicker( - modifier = Modifier.fillMaxWidth(.4f), - value = trackAndService.service.scoreList[currentIndex], - onValueChange = { newScore -> - currentIndex = trackAndService.service.scoreList.indexOf(newScore) + AlertDialog( + title = { + Text( + text = stringResource(id = R.string.score), + textAlign = TextAlign.Center, + modifier = Modifier.fillMaxWidth()) + }, + text = { + Box( + contentAlignment = Alignment.Center, + modifier = Modifier.padding(16.dp).fillMaxWidth(), + ) { + ListItemPicker( + modifier = Modifier.fillMaxWidth(.4f), + value = trackAndService.service.scoreList[currentIndex], + onValueChange = { newScore -> + currentIndex = trackAndService.service.scoreList.indexOf(newScore) + }, + list = trackAndService.service.scoreList, + dividersColor = themeColorState.buttonColor, + textStyle = + MaterialTheme.typography.titleMedium.copy( + color = MaterialTheme.colorScheme.onSurface), + ) + } + }, + onDismissRequest = onDismiss, + dismissButton = { + TextButton( + onClick = onDismiss, + colors = + ButtonDefaults.textButtonColors( + contentColor = themeColorState.buttonColor)) { + Text(text = stringResource(id = R.string.cancel)) + } + }, + confirmButton = { + TextButton( + onClick = { + trackScoreChange(currentIndex) + onDismiss() }, - list = trackAndService.service.scoreList, - dividersColor = themeColorState.buttonColor, - textStyle = - MaterialTheme.typography.titleMedium.copy( - color = MaterialTheme.colorScheme.onSurface - ), - ) - } - }, - onDismissRequest = onDismiss, - dismissButton = { - TextButton( - onClick = onDismiss, - colors = - ButtonDefaults.textButtonColors(contentColor = themeColorState.buttonColor) - ) { - Text(text = stringResource(id = R.string.cancel)) - } - }, - confirmButton = { - TextButton( - onClick = { - trackScoreChange(currentIndex) - onDismiss() - }, - colors = - ButtonDefaults.textButtonColors(contentColor = themeColorState.buttonColor), - ) { - Text(text = stringResource(id = android.R.string.ok)) - } - }, - ) - } + colors = + ButtonDefaults.textButtonColors( + contentColor = themeColorState.buttonColor), + ) { + Text(text = stringResource(id = android.R.string.ok)) + } + }, + ) + } } diff --git a/app/src/main/java/org/nekomanga/presentation/components/dialog/TrackingStatusDialog.kt b/app/src/main/java/org/nekomanga/presentation/components/dialog/TrackingStatusDialog.kt index 286cd22697..4d6106fbac 100644 --- a/app/src/main/java/org/nekomanga/presentation/components/dialog/TrackingStatusDialog.kt +++ b/app/src/main/java/org/nekomanga/presentation/components/dialog/TrackingStatusDialog.kt @@ -42,66 +42,62 @@ fun TrackingStatusDialog( ) { CompositionLocalProvider( LocalRippleTheme provides themeColorState.rippleTheme, - LocalTextSelectionColors provides themeColorState.textSelectionColors - ) { - var selectedStatus by remember { mutableStateOf(initialStatus) } - val scope = rememberCoroutineScope() - AlertDialog( - title = { - Text( - text = stringResource(id = R.string.status), - textAlign = TextAlign.Center, - modifier = Modifier.fillMaxWidth() - ) - }, - text = { - Column(modifier = Modifier.fillMaxWidth()) { - service.statusList.forEachIndexed { index, status -> - val clicked = { - selectedStatus = status - scope.launch { - delay(100L) - trackStatusChange(index) - onDismiss() + LocalTextSelectionColors provides themeColorState.textSelectionColors) { + var selectedStatus by remember { mutableStateOf(initialStatus) } + val scope = rememberCoroutineScope() + AlertDialog( + title = { + Text( + text = stringResource(id = R.string.status), + textAlign = TextAlign.Center, + modifier = Modifier.fillMaxWidth()) + }, + text = { + Column(modifier = Modifier.fillMaxWidth()) { + service.statusList.forEachIndexed { index, status -> + val clicked = { + selectedStatus = status + scope.launch { + delay(100L) + trackStatusChange(index) + onDismiss() + } } - } - Row( - modifier = - Modifier.fillMaxWidth() - .selectable( - selected = (status == selectedStatus), - onClick = { clicked() }, - ), - verticalAlignment = Alignment.CenterVertically, - ) { - RadioButton( - selected = (status == selectedStatus), - onClick = { clicked() }, - colors = - RadioButtonDefaults.colors( - selectedColor = themeColorState.buttonColor - ), - ) - Gap(Size.small) - Text( - text = service.status(status), - style = MaterialTheme.typography.titleMedium - ) + Row( + modifier = + Modifier.fillMaxWidth() + .selectable( + selected = (status == selectedStatus), + onClick = { clicked() }, + ), + verticalAlignment = Alignment.CenterVertically, + ) { + RadioButton( + selected = (status == selectedStatus), + onClick = { clicked() }, + colors = + RadioButtonDefaults.colors( + selectedColor = themeColorState.buttonColor), + ) + Gap(Size.small) + Text( + text = service.status(status), + style = MaterialTheme.typography.titleMedium) + } } } - } - }, - onDismissRequest = onDismiss, - confirmButton = { - TextButton( - onClick = onDismiss, - colors = - ButtonDefaults.textButtonColors(contentColor = themeColorState.buttonColor) - ) { - Text(text = stringResource(id = R.string.cancel)) - } - }, - ) - } + }, + onDismissRequest = onDismiss, + confirmButton = { + TextButton( + onClick = onDismiss, + colors = + ButtonDefaults.textButtonColors( + contentColor = themeColorState.buttonColor)) { + Text(text = stringResource(id = R.string.cancel)) + } + }, + ) + } } diff --git a/app/src/main/java/org/nekomanga/presentation/components/dialog/TrackingSwitchDialog.kt b/app/src/main/java/org/nekomanga/presentation/components/dialog/TrackingSwitchDialog.kt index 89e1bf90de..3dba9cd281 100644 --- a/app/src/main/java/org/nekomanga/presentation/components/dialog/TrackingSwitchDialog.kt +++ b/app/src/main/java/org/nekomanga/presentation/components/dialog/TrackingSwitchDialog.kt @@ -28,46 +28,43 @@ fun TrackingSwitchDialog( ) { CompositionLocalProvider( LocalRippleTheme provides themeColorState.rippleTheme, - LocalTextSelectionColors provides themeColorState.textSelectionColors - ) { - AlertDialog( - title = { Text(text = stringResource(id = R.string.remove_previous_tracker)) }, - text = { - Column { - TextButton( - onClick = { onConfirm(true) }, - modifier = Modifier.fillMaxWidth(), - ) { - Text( - text = - stringResource( - id = R.string.remove_x_from_service_and_add_y, - oldName, - name, - newName - ) - ) - } + LocalTextSelectionColors provides themeColorState.textSelectionColors) { + AlertDialog( + title = { Text(text = stringResource(id = R.string.remove_previous_tracker)) }, + text = { + Column { + TextButton( + onClick = { onConfirm(true) }, + modifier = Modifier.fillMaxWidth(), + ) { + Text( + text = + stringResource( + id = R.string.remove_x_from_service_and_add_y, + oldName, + name, + newName)) + } - Gap(Size.small) - TextButton( - onClick = { onConfirm(false) }, - modifier = Modifier.fillMaxWidth(), - ) { - Text(text = stringResource(id = R.string.keep_both_on_service, name)) + Gap(Size.small) + TextButton( + onClick = { onConfirm(false) }, + modifier = Modifier.fillMaxWidth(), + ) { + Text(text = stringResource(id = R.string.keep_both_on_service, name)) + } } - } - }, - onDismissRequest = onDismiss, - confirmButton = { - TextButton( - onClick = onDismiss, - colors = - ButtonDefaults.textButtonColors(contentColor = themeColorState.buttonColor) - ) { - Text(text = stringResource(id = R.string.cancel)) - } - }, - ) - } + }, + onDismissRequest = onDismiss, + confirmButton = { + TextButton( + onClick = onDismiss, + colors = + ButtonDefaults.textButtonColors( + contentColor = themeColorState.buttonColor)) { + Text(text = stringResource(id = R.string.cancel)) + } + }, + ) + } } diff --git a/app/src/main/java/org/nekomanga/presentation/components/dropdown/MainDropdownMenu.kt b/app/src/main/java/org/nekomanga/presentation/components/dropdown/MainDropdownMenu.kt index 8a14820f51..bce6e8792a 100644 --- a/app/src/main/java/org/nekomanga/presentation/components/dropdown/MainDropdownMenu.kt +++ b/app/src/main/java/org/nekomanga/presentation/components/dropdown/MainDropdownMenu.kt @@ -128,10 +128,7 @@ private fun Row( text = title.asString(), style = MaterialTheme.typography.bodyMedium.copy( - color = MaterialTheme.colorScheme.onSurface, - letterSpacing = (-.5).sp - ) - ) + color = MaterialTheme.colorScheme.onSurface, letterSpacing = (-.5).sp)) if (subTitle != null) { Text( text = subTitle.asString(), @@ -139,10 +136,8 @@ private fun Row( MaterialTheme.typography.bodySmall.copy( color = MaterialTheme.colorScheme.onSurface.copy( - alpha = NekoColors.mediumAlphaLowContrast - ), - letterSpacing = (-.5).sp - ), + alpha = NekoColors.mediumAlphaLowContrast), + letterSpacing = (-.5).sp), ) } } @@ -154,14 +149,12 @@ private fun Row( imageVector = icon.icon, modifier = Modifier.size(24.dp), contentDescription = null, - tint = MaterialTheme.colorScheme.onSurface - ) + tint = MaterialTheme.colorScheme.onSurface) is UiIcon.IIcon -> Image( asset = icon.icon, modifier = Modifier.size(24.dp), - colorFilter = ColorFilter.tint(color = MaterialTheme.colorScheme.onSurface) - ) + colorFilter = ColorFilter.tint(color = MaterialTheme.colorScheme.onSurface)) } }, onClick = { diff --git a/app/src/main/java/org/nekomanga/presentation/components/dropdown/SimpleDropdownMenu.kt b/app/src/main/java/org/nekomanga/presentation/components/dropdown/SimpleDropdownMenu.kt index c369a0c13b..e482329fee 100644 --- a/app/src/main/java/org/nekomanga/presentation/components/dropdown/SimpleDropdownMenu.kt +++ b/app/src/main/java/org/nekomanga/presentation/components/dropdown/SimpleDropdownMenu.kt @@ -32,10 +32,7 @@ fun SimpleDropdownMenu( Modifier.background( color = MaterialTheme.colorScheme.surfaceColorAtElevationCustomColor( - themeColorState.buttonColor, - 8.dp - ) - ) + themeColorState.buttonColor, 8.dp)) CascadeDropdownMenu( expanded = expanded, offset = DpOffset(Size.small, Size.small), @@ -46,9 +43,7 @@ fun SimpleDropdownMenu( ) { val style = MaterialTheme.typography.bodyLarge.copy( - color = MaterialTheme.colorScheme.onSurface, - letterSpacing = (-.5).sp - ) + color = MaterialTheme.colorScheme.onSurface, letterSpacing = (-.5).sp) dropDownItems.forEach { item -> Row(modifier = background, item = item, style = style, onDismiss = onDismiss) } @@ -96,8 +91,7 @@ private fun CascadeColumnScope.Row( text = item.text.asString(), style = style, onClick = item.onClick, - onDismiss = onDismiss - ) + onDismiss = onDismiss) } } } diff --git a/app/src/main/java/org/nekomanga/presentation/components/sheets/ArtworkSheet.kt b/app/src/main/java/org/nekomanga/presentation/components/sheets/ArtworkSheet.kt index cfafdd3153..3710c46ff2 100644 --- a/app/src/main/java/org/nekomanga/presentation/components/sheets/ArtworkSheet.kt +++ b/app/src/main/java/org/nekomanga/presentation/components/sheets/ArtworkSheet.kt @@ -70,117 +70,113 @@ fun ArtworkSheet( ) { CompositionLocalProvider( LocalRippleTheme provides themeColorState.rippleTheme, - LocalTextSelectionColors provides themeColorState.textSelectionColors - ) { - if (alternativeArtwork.isEmpty()) { - BaseSheet(themeColor = themeColorState) { - Text( - text = "Please swipe refresh to pull latest artwork", - textAlign = TextAlign.Center, - modifier = Modifier.fillMaxWidth(), - ) - } - } else { - var currentImage by remember { - mutableStateOf( - alternativeArtwork.firstOrNull { it.active } ?: alternativeArtwork.first() - ) - } - - val screenHeight = LocalConfiguration.current.screenHeightDp - val thumbnailSize = (screenHeight * .12f).dp - val imageHeight = screenHeight * .7f - val gradientHeight = (thumbnailSize / 2f) + LocalTextSelectionColors provides themeColorState.textSelectionColors) { + if (alternativeArtwork.isEmpty()) { + BaseSheet(themeColor = themeColorState) { + Text( + text = "Please swipe refresh to pull latest artwork", + textAlign = TextAlign.Center, + modifier = Modifier.fillMaxWidth(), + ) + } + } else { + var currentImage by remember { + mutableStateOf( + alternativeArtwork.firstOrNull { it.active } ?: alternativeArtwork.first()) + } - Column( - modifier = - Modifier.fillMaxWidth() - .fillMaxHeight(.95f) - .background(MaterialTheme.colorScheme.surface) - .statusBarsPadding() - .navigationBarsPadding(), - horizontalAlignment = Alignment.CenterHorizontally, - ) { - AsyncImage( - model = ImageRequest.Builder(LocalContext.current).data(currentImage).build(), - contentDescription = null, - contentScale = ContentScale.Fit, - modifier = Modifier.height(imageHeight.dp).padding(horizontal = Size.small), - ) + val screenHeight = LocalConfiguration.current.screenHeightDp + val thumbnailSize = (screenHeight * .12f).dp + val imageHeight = screenHeight * .7f + val gradientHeight = (thumbnailSize / 2f) - Row( - modifier = Modifier.fillMaxWidth().padding(Size.tiny), - Arrangement.spacedBy(Size.tiny), + Column( + modifier = + Modifier.fillMaxWidth() + .fillMaxHeight(.95f) + .background(MaterialTheme.colorScheme.surface) + .statusBarsPadding() + .navigationBarsPadding(), + horizontalAlignment = Alignment.CenterHorizontally, ) { - ArtworkButton( - text = stringResource(id = R.string.save), - color = themeColorState.buttonColor, - modifier = Modifier.weight(1f) + AsyncImage( + model = + ImageRequest.Builder(LocalContext.current).data(currentImage).build(), + contentDescription = null, + contentScale = ContentScale.Fit, + modifier = Modifier.height(imageHeight.dp).padding(horizontal = Size.small), + ) + + Row( + modifier = Modifier.fillMaxWidth().padding(Size.tiny), + Arrangement.spacedBy(Size.tiny), ) { - saveClick(currentImage) - } - if (inLibrary) { ArtworkButton( - text = stringResource(id = R.string.set), + text = stringResource(id = R.string.save), color = themeColorState.buttonColor, - modifier = Modifier.weight(1f) - ) { - setClick(currentImage) + modifier = Modifier.weight(1f)) { + saveClick(currentImage) + } + if (inLibrary) { + ArtworkButton( + text = stringResource(id = R.string.set), + color = themeColorState.buttonColor, + modifier = Modifier.weight(1f)) { + setClick(currentImage) + } + ArtworkButton( + text = stringResource(id = R.string.reset), + color = themeColorState.buttonColor, + modifier = Modifier.weight(1f)) { + resetClick() + } } ArtworkButton( - text = stringResource(id = R.string.reset), + text = stringResource(id = R.string.share), color = themeColorState.buttonColor, - modifier = Modifier.weight(1f) - ) { - resetClick() - } + modifier = Modifier.weight(1f)) { + shareClick(currentImage) + } } - ArtworkButton( - text = stringResource(id = R.string.share), - color = themeColorState.buttonColor, - modifier = Modifier.weight(1f) - ) { - shareClick(currentImage) + if (currentImage.description.isNotBlank()) { + Text( + text = currentImage.description, + modifier = Modifier.padding(horizontal = Size.small), + color = MaterialTheme.colorScheme.onSurface, + style = MaterialTheme.typography.labelMedium, + ) } - } - if (currentImage.description.isNotBlank()) { - Text( - text = currentImage.description, - modifier = Modifier.padding(horizontal = Size.small), - color = MaterialTheme.colorScheme.onSurface, - style = MaterialTheme.typography.labelMedium, - ) - } - Gap(Size.small) - if (alternativeArtwork.size > 1) { - Column( - modifier = Modifier.fillMaxSize(), - verticalArrangement = Arrangement.spacedBy(Size.tiny, Alignment.Bottom) - ) { - LazyRow(horizontalArrangement = Arrangement.spacedBy(Size.tiny)) { - items(alternativeArtwork) { artwork -> - Box { - Thumbnail( - artwork = artwork, - thumbnailSize = thumbnailSize, - ) { - currentImage = artwork - } - if (artwork.active) { - ActiveIndicator(themeColorState) - } - if (artwork.volume.isNotBlank()) { - VolumeSection(thumbnailSize, gradientHeight, artwork) + Gap(Size.small) + if (alternativeArtwork.size > 1) { + Column( + modifier = Modifier.fillMaxSize(), + verticalArrangement = + Arrangement.spacedBy(Size.tiny, Alignment.Bottom)) { + LazyRow(horizontalArrangement = Arrangement.spacedBy(Size.tiny)) { + items(alternativeArtwork) { artwork -> + Box { + Thumbnail( + artwork = artwork, + thumbnailSize = thumbnailSize, + ) { + currentImage = artwork + } + if (artwork.active) { + ActiveIndicator(themeColorState) + } + if (artwork.volume.isNotBlank()) { + VolumeSection( + thumbnailSize, gradientHeight, artwork) + } + } } } } - } + Gap(Size.small) } - Gap(Size.small) } } } - } } @Composable @@ -224,10 +220,7 @@ private fun BoxScope.VolumeSection(thumbnailSize: Dp, gradientHeight: Dp, artwor .height(gradientHeight) .clip( RoundedCornerShape( - bottomStart = Shapes.coverRadius, - bottomEnd = Shapes.coverRadius - ) - ) + bottomStart = Shapes.coverRadius, bottomEnd = Shapes.coverRadius)) .background( Brush.verticalGradient( colors = listOf(Color.Transparent, MaterialTheme.colorScheme.onSurface), @@ -256,7 +249,6 @@ private fun ActiveIndicator(themeColorState: ThemeColorState) { imageVector = Icons.Filled.Star, modifier = Modifier.padding(Size.tiny), contentDescription = null, - tint = themeColorState.buttonColor - ) + tint = themeColorState.buttonColor) } } diff --git a/app/src/main/java/org/nekomanga/presentation/components/sheets/BaseSheet.kt b/app/src/main/java/org/nekomanga/presentation/components/sheets/BaseSheet.kt index a2867fb0b5..16b732f1ff 100644 --- a/app/src/main/java/org/nekomanga/presentation/components/sheets/BaseSheet.kt +++ b/app/src/main/java/org/nekomanga/presentation/components/sheets/BaseSheet.kt @@ -33,27 +33,27 @@ fun BaseSheet( ) { CompositionLocalProvider( LocalRippleTheme provides themeColor.rippleTheme, - LocalTextSelectionColors provides themeColor.textSelectionColors - ) { - val screenHeight = LocalConfiguration.current.screenHeightDp - val maxSheetHeight = screenHeight * maxSheetHeightPercentage - val minSheetHeight = screenHeight * minSheetHeightPercentage - ElevatedCard( - modifier = - Modifier.fillMaxWidth().requiredHeightIn(minSheetHeight.dp, maxSheetHeight.dp), - shape = RoundedCornerShape(topStart = Shapes.sheetRadius, topEnd = Shapes.sheetRadius), - ) { - Column( - modifier = Modifier.navigationBarsPadding().imePadding(), + LocalTextSelectionColors provides themeColor.textSelectionColors) { + val screenHeight = LocalConfiguration.current.screenHeightDp + val maxSheetHeight = screenHeight * maxSheetHeightPercentage + val minSheetHeight = screenHeight * minSheetHeightPercentage + ElevatedCard( + modifier = + Modifier.fillMaxWidth().requiredHeightIn(minSheetHeight.dp, maxSheetHeight.dp), + shape = + RoundedCornerShape(topStart = Shapes.sheetRadius, topEnd = Shapes.sheetRadius), ) { - if (showHandle) { - sheetHandle() - } + Column( + modifier = Modifier.navigationBarsPadding().imePadding(), + ) { + if (showHandle) { + sheetHandle() + } - Gap(topPaddingAroundContent) - content() - Gap(bottomPaddingAroundContent) + Gap(topPaddingAroundContent) + content() + Gap(bottomPaddingAroundContent) + } } } - } } diff --git a/app/src/main/java/org/nekomanga/presentation/components/sheets/EditCategorySheet.kt b/app/src/main/java/org/nekomanga/presentation/components/sheets/EditCategorySheet.kt index 93d590c422..1c3888c6fa 100644 --- a/app/src/main/java/org/nekomanga/presentation/components/sheets/EditCategorySheet.kt +++ b/app/src/main/java/org/nekomanga/presentation/components/sheets/EditCategorySheet.kt @@ -58,8 +58,7 @@ fun EditCategorySheet( val enabledCategories = remember { mangaCategories.associateBy { it.id }.toMutableMap() } val acceptText = remember { mutableStateOf( - calculateText(context, mangaCategories, enabledCategories, addingToLibrary) - ) + calculateText(context, mangaCategories, enabledCategories, addingToLibrary)) } var showAddCategoryDialog by remember { mutableStateOf(false) } @@ -69,110 +68,102 @@ fun EditCategorySheet( BaseSheet( themeColor = themeColorState, maxSheetHeightPercentage = .9f, - bottomPaddingAroundContent = bottomContentPadding - ) { - if (showAddCategoryDialog) { - AddCategoryDialog( - themeColorState = themeColorState, - currentCategories = categories, - onDismiss = { showAddCategoryDialog = false }, - onConfirm = { addNewCategory(it) } - ) - } - - val paddingModifier = Modifier.padding(horizontal = Size.small) - - Gap(16.dp) - Row( - modifier = paddingModifier.fillMaxWidth(), - horizontalArrangement = Arrangement.SpaceBetween, - verticalAlignment = Alignment.CenterVertically - ) { - val prefix = if (addingToLibrary) R.string.add_x_to else R.string.move_x_to - Text( - modifier = paddingModifier, - text = stringResource(id = prefix, stringResource(id = R.string.manga)), - style = MaterialTheme.typography.titleLarge - ) - TextButton(modifier = paddingModifier, onClick = { showAddCategoryDialog = true }) { - Text( - text = stringResource(id = R.string.plus_new_category), - style = - MaterialTheme.typography.titleSmall.copy( - color = themeColorState.buttonColor - ) - ) + bottomPaddingAroundContent = bottomContentPadding) { + if (showAddCategoryDialog) { + AddCategoryDialog( + themeColorState = themeColorState, + currentCategories = categories, + onDismiss = { showAddCategoryDialog = false }, + onConfirm = { addNewCategory(it) }) } - } - Gap(16.dp) - Divider() - LazyColumn( - modifier = Modifier.fillMaxWidth().requiredHeightIn(Size.none, maxLazyHeight.dp), - ) { - items(categories) { category: CategoryItem -> - var state by remember { - mutableStateOf(enabledCategories.contains(category.id)) - } - CheckboxRow( - modifier = Modifier.fillMaxWidth(), - checkedState = state, - checkedChange = { newState -> - state = newState - if (state) { - enabledCategories[category.id] = category - } else { - enabledCategories.remove(category.id) + val paddingModifier = Modifier.padding(horizontal = Size.small) + + Gap(16.dp) + Row( + modifier = paddingModifier.fillMaxWidth(), + horizontalArrangement = Arrangement.SpaceBetween, + verticalAlignment = Alignment.CenterVertically) { + val prefix = if (addingToLibrary) R.string.add_x_to else R.string.move_x_to + Text( + modifier = paddingModifier, + text = stringResource(id = prefix, stringResource(id = R.string.manga)), + style = MaterialTheme.typography.titleLarge) + TextButton( + modifier = paddingModifier, + onClick = { showAddCategoryDialog = true }) { + Text( + text = stringResource(id = R.string.plus_new_category), + style = + MaterialTheme.typography.titleSmall.copy( + color = themeColorState.buttonColor)) } - acceptText.value = - calculateText( - context, - mangaCategories, - enabledCategories, - addingToLibrary - ) - }, - rowText = category.name, - themeColorState = themeColorState, - ) - } - } + } + Gap(16.dp) + Divider() - Divider() - Gap(Size.tiny) - Row( - modifier = paddingModifier.fillMaxWidth(), - horizontalArrangement = Arrangement.SpaceBetween - ) { - TextButton( - onClick = cancelClick, - colors = - ButtonDefaults.textButtonColors(contentColor = themeColorState.buttonColor) - ) { - Text( - text = stringResource(id = R.string.cancel), - style = MaterialTheme.typography.titleSmall - ) - } - ElevatedButton( - onClick = { - confirmClicked(enabledCategories.values.toList()) - addToLibraryClick() - cancelClick() - }, - colors = - ButtonDefaults.elevatedButtonColors( - containerColor = themeColorState.buttonColor - ), + LazyColumn( + modifier = + Modifier.fillMaxWidth().requiredHeightIn(Size.none, maxLazyHeight.dp), ) { - Text( - text = acceptText.value, - style = MaterialTheme.typography.titleSmall, - color = MaterialTheme.colorScheme.surface - ) + items(categories) { category: CategoryItem -> + var state by remember { + mutableStateOf(enabledCategories.contains(category.id)) + } + CheckboxRow( + modifier = Modifier.fillMaxWidth(), + checkedState = state, + checkedChange = { newState -> + state = newState + if (state) { + enabledCategories[category.id] = category + } else { + enabledCategories.remove(category.id) + } + acceptText.value = + calculateText( + context, + mangaCategories, + enabledCategories, + addingToLibrary) + }, + rowText = category.name, + themeColorState = themeColorState, + ) + } } + + Divider() + Gap(Size.tiny) + Row( + modifier = paddingModifier.fillMaxWidth(), + horizontalArrangement = Arrangement.SpaceBetween) { + TextButton( + onClick = cancelClick, + colors = + ButtonDefaults.textButtonColors( + contentColor = themeColorState.buttonColor)) { + Text( + text = stringResource(id = R.string.cancel), + style = MaterialTheme.typography.titleSmall) + } + ElevatedButton( + onClick = { + confirmClicked(enabledCategories.values.toList()) + addToLibraryClick() + cancelClick() + }, + colors = + ButtonDefaults.elevatedButtonColors( + containerColor = themeColorState.buttonColor), + ) { + Text( + text = acceptText.value, + style = MaterialTheme.typography.titleSmall, + color = MaterialTheme.colorScheme.surface) + } + } } - } } } diff --git a/app/src/main/java/org/nekomanga/presentation/components/sheets/ExternalLinksSheet.kt b/app/src/main/java/org/nekomanga/presentation/components/sheets/ExternalLinksSheet.kt index 59ce5d10bc..3e3330c493 100644 --- a/app/src/main/java/org/nekomanga/presentation/components/sheets/ExternalLinksSheet.kt +++ b/app/src/main/java/org/nekomanga/presentation/components/sheets/ExternalLinksSheet.kt @@ -69,8 +69,7 @@ private fun LinkCard(externalLink: ExternalLink, onLinkClick: (String, String) - text = externalLink.name, style = MaterialTheme.typography.bodyMedium.copy( - color = Color(externalLink.onLogoColor) - ), + color = Color(externalLink.onLogoColor)), ) Gap(12.dp) } diff --git a/app/src/main/java/org/nekomanga/presentation/components/sheets/FilterBrowseSheet.kt b/app/src/main/java/org/nekomanga/presentation/components/sheets/FilterBrowseSheet.kt index 72ffe809d5..3dc641829e 100644 --- a/app/src/main/java/org/nekomanga/presentation/components/sheets/FilterBrowseSheet.kt +++ b/app/src/main/java/org/nekomanga/presentation/components/sheets/FilterBrowseSheet.kt @@ -140,8 +140,7 @@ fun FilterBrowseSheet( themeColorState = themeColorState, currentSavedFilters = savedFilters, onDismiss = { showSaveFilterDialog = false }, - onConfirm = { saveClick(it) } - ) + onConfirm = { saveClick(it) }) } var queryText by remember { mutableStateOf(filters.query.text) } @@ -362,60 +361,49 @@ fun FilterBrowseSheet( Icon( imageVector = Icons.Default.RestartAlt, contentDescription = null, - tint = themeColorState.buttonColor - ) + tint = themeColorState.buttonColor) Gap(Size.tiny) Text( text = stringResource(id = R.string.reset), - style = MaterialTheme.typography.titleSmall - ) + style = MaterialTheme.typography.titleSmall) } AnimatedVisibility( - nameOfEnabledFilter.isEmpty(), - enter = fadeIn(), - exit = fadeOut() - ) { - TextButton( - onClick = { showSaveFilterDialog = true }, - shape = RoundedCornerShape(35), - colors = - ButtonDefaults.textButtonColors( - contentColor = themeColorState.buttonColor - ), - ) { - Icon( - imageVector = Icons.Default.Save, - contentDescription = null, - tint = themeColorState.buttonColor - ) - Gap(Size.tiny) - Text( - text = stringResource(id = R.string.save), - style = MaterialTheme.typography.titleSmall - ) + nameOfEnabledFilter.isEmpty(), enter = fadeIn(), exit = fadeOut()) { + TextButton( + onClick = { showSaveFilterDialog = true }, + shape = RoundedCornerShape(35), + colors = + ButtonDefaults.textButtonColors( + contentColor = themeColorState.buttonColor), + ) { + Icon( + imageVector = Icons.Default.Save, + contentDescription = null, + tint = themeColorState.buttonColor) + Gap(Size.tiny) + Text( + text = stringResource(id = R.string.save), + style = MaterialTheme.typography.titleSmall) + } } - } ElevatedButton( onClick = filterClick, shape = RoundedCornerShape(35), colors = ButtonDefaults.elevatedButtonColors( - containerColor = themeColorState.buttonColor - ), + containerColor = themeColorState.buttonColor), ) { Icon( imageVector = Icons.Default.Search, contentDescription = null, - tint = MaterialTheme.colorScheme.surface - ) + tint = MaterialTheme.colorScheme.surface) Gap(Size.tiny) Text( text = stringResource(id = R.string.filter), style = MaterialTheme.typography.titleSmall, - color = MaterialTheme.colorScheme.surface - ) + color = MaterialTheme.colorScheme.surface) } } @@ -468,10 +456,7 @@ private fun FilterRow( else -> "" } FilterChipWrapper( - selected = selected(item), - onClick = { onClick(item) }, - name = itemName - ) + selected = selected(item), onClick = { onClick(item) }, name = itemName) } } } @@ -524,8 +509,7 @@ private fun FilterTriStateRow( TriStateFilterChip( state = selected(item), toggleState = { state -> toggleState(state, item) }, - name = itemName - ) + name = itemName) } } } @@ -574,8 +558,7 @@ fun OtherRow( Text( text = stringResource(id = R.string.tag_inclusion_mode), modifier = Modifier.padding(start = Size.small), - style = MaterialTheme.typography.labelMedium - ) + style = MaterialTheme.typography.labelMedium) Row(verticalAlignment = Alignment.CenterVertically) { RadioButton( selected = filters.tagInclusionMode.mode == TagMode.And, @@ -585,8 +568,7 @@ fun OtherRow( ) Text( text = stringResource(id = R.string.and), - color = MaterialTheme.colorScheme.onSurface - ) + color = MaterialTheme.colorScheme.onSurface) RadioButton( selected = filters.tagInclusionMode.mode == TagMode.Or, onClick = { @@ -595,8 +577,7 @@ fun OtherRow( ) Text( text = stringResource(id = R.string.or), - color = MaterialTheme.colorScheme.onSurface - ) + color = MaterialTheme.colorScheme.onSurface) } } @@ -604,8 +585,7 @@ fun OtherRow( Text( text = stringResource(id = R.string.tag_exclusion_mode), modifier = Modifier.padding(start = Size.small), - style = MaterialTheme.typography.labelMedium - ) + style = MaterialTheme.typography.labelMedium) Row(verticalAlignment = Alignment.CenterVertically) { RadioButton( selected = filters.tagExclusionMode.mode == TagMode.And, @@ -615,8 +595,7 @@ fun OtherRow( ) Text( text = stringResource(id = R.string.and), - color = MaterialTheme.colorScheme.onSurface - ) + color = MaterialTheme.colorScheme.onSurface) RadioButton( selected = filters.tagExclusionMode.mode == TagMode.Or, onClick = { @@ -625,8 +604,7 @@ fun OtherRow( ) Text( text = stringResource(id = R.string.or), - color = MaterialTheme.colorScheme.onSurface - ) + color = MaterialTheme.colorScheme.onSurface) } } @@ -693,8 +671,7 @@ fun SavedFilters( val mutableFilters = savedFilters.toMutableList() val enabledFilter = mutableFilters.removeAt(enabledFilterIndex) mutableStateOf( - persistentListOf(enabledFilter) + mutableFilters.toImmutableList() - ) + persistentListOf(enabledFilter) + mutableFilters.toImmutableList()) } } val listState: LazyListState = rememberLazyListState() @@ -720,8 +697,7 @@ fun SavedFilters( ToolTipButton( toolTipLabel = stringResource(id = R.string.delete_filter), icon = Icons.Outlined.Delete, - buttonClicked = { deleteFilterClick(nameOfEnabledFilter) } - ) + buttonClicked = { deleteFilterClick(nameOfEnabledFilter) }) val isDefault = savedFilters .firstOrNull { nameOfEnabledFilter.equals(it.name, true) } @@ -732,8 +708,7 @@ fun SavedFilters( Triple( R.string.remove_default, false, - Icons.Default.HeartBroken - ) + Icons.Default.HeartBroken) false -> Triple(R.string.make_default, true, Icons.Default.Favorite) } @@ -742,8 +717,7 @@ fun SavedFilters( icon = icon, buttonClicked = { filterDefaultClick(nameOfEnabledFilter, makeDefault) - } - ) + }) } } Gap(Size.tiny) diff --git a/app/src/main/java/org/nekomanga/presentation/components/sheets/FilterChapterSheet.kt b/app/src/main/java/org/nekomanga/presentation/components/sheets/FilterChapterSheet.kt index 411be55f4a..f82a1d7e3c 100644 --- a/app/src/main/java/org/nekomanga/presentation/components/sheets/FilterChapterSheet.kt +++ b/app/src/main/java/org/nekomanga/presentation/components/sheets/FilterChapterSheet.kt @@ -66,17 +66,11 @@ fun FilterChapterSheet( item { Scanlator( - themeColorState = themeColorState, - scanlatorFilter, - changeScanlatorFilter - ) + themeColorState = themeColorState, scanlatorFilter, changeScanlatorFilter) } item { Language( - themeColorState = themeColorState, - languageFilter, - changeLanguageFilter - ) + themeColorState = themeColorState, languageFilter, changeLanguageFilter) } } } @@ -102,22 +96,19 @@ private fun Sort( modifier = Modifier.padding(vertical = 16.dp), text = stringResource(id = R.string.sort), style = MaterialTheme.typography.labelMedium, - color = MaterialTheme.colorScheme.onSurface - ) + color = MaterialTheme.colorScheme.onSurface) if (!sortFilter.matchesGlobalDefaults) { TextButton(onClick = setGlobal) { Text( text = stringResource(id = R.string.set_as_default), style = MaterialTheme.typography.labelMedium, - color = themeColorState.buttonColor - ) + color = themeColorState.buttonColor) } TextButton(onClick = { changeSort(null) }) { Text( text = stringResource(id = R.string.reset), style = MaterialTheme.typography.labelMedium, - color = themeColorState.buttonColor - ) + color = themeColorState.buttonColor) } } } @@ -126,20 +117,17 @@ private fun Sort( themeColorState, SortOption(sortFilter.sourceOrderSort, SourceOrder), stringResource(id = R.string.by_source_order), - changeSort - ) + changeSort) SortLine( themeColorState, SortOption(sortFilter.chapterNumberSort, ChapterNumber), stringResource(id = R.string.by_chapter_number), - changeSort - ) + changeSort) SortLine( themeColorState, SortOption(sortFilter.uploadDateSort, UploadDate), stringResource(id = R.string.by_update_date), - changeSort - ) + changeSort) } } @@ -186,15 +174,13 @@ private fun Filter( Text( text = stringResource(id = R.string.set_as_default), style = MaterialTheme.typography.labelMedium, - color = themeColorState.buttonColor - ) + color = themeColorState.buttonColor) } TextButton(onClick = { changeFilter(null) }) { Text( text = stringResource(id = R.string.reset), style = MaterialTheme.typography.labelMedium, - color = themeColorState.buttonColor - ) + color = themeColorState.buttonColor) } } } @@ -207,9 +193,7 @@ private fun Filter( changeFilter( MangaConstants.ChapterDisplayOptions( displayType = MangaConstants.ChapterDisplayType.All, - displayState = ToggleableState(!filter.showAll) - ) - ) + displayState = ToggleableState(!filter.showAll))) }, ) FilterLine( @@ -217,8 +201,7 @@ private fun Filter( state = MangaConstants.ChapterDisplayOptions( displayType = MangaConstants.ChapterDisplayType.Unread, - displayState = filter.unread - ), + displayState = filter.unread), text = stringResource(id = R.string.show_unread_chapters), changeFilter = changeFilter, ) @@ -227,8 +210,7 @@ private fun Filter( state = MangaConstants.ChapterDisplayOptions( displayType = MangaConstants.ChapterDisplayType.Downloaded, - displayState = filter.downloaded - ), + displayState = filter.downloaded), text = stringResource(id = R.string.show_downloaded_chapters), changeFilter = changeFilter, ) @@ -237,8 +219,7 @@ private fun Filter( state = MangaConstants.ChapterDisplayOptions( displayType = MangaConstants.ChapterDisplayType.Bookmarked, - displayState = filter.bookmarked - ), + displayState = filter.bookmarked), text = stringResource(id = R.string.show_bookmarked_chapters), changeFilter = changeFilter, ) @@ -293,8 +274,7 @@ private fun CheckboxLine( checkedChange = { onChecked() }, rowText = text, themeColorState = themeColorState, - disabled = disabledOnChecked && checked - ) + disabled = disabledOnChecked && checked) } @Composable @@ -322,8 +302,7 @@ private fun Scanlator( Text( text = stringResource(id = R.string.reset), style = MaterialTheme.typography.labelMedium, - color = themeColorState.buttonColor - ) + color = themeColorState.buttonColor) } } } @@ -385,8 +364,7 @@ private fun Language( Text( text = stringResource(id = R.string.reset), style = MaterialTheme.typography.labelMedium, - color = themeColorState.buttonColor - ) + color = themeColorState.buttonColor) } } } diff --git a/app/src/main/java/org/nekomanga/presentation/components/sheets/MergeSheet.kt b/app/src/main/java/org/nekomanga/presentation/components/sheets/MergeSheet.kt index 4c117655c0..e139cbf932 100644 --- a/app/src/main/java/org/nekomanga/presentation/components/sheets/MergeSheet.kt +++ b/app/src/main/java/org/nekomanga/presentation/components/sheets/MergeSheet.kt @@ -87,30 +87,25 @@ fun MergeSheet( text = stringResource(id = R.string.merge_source_, text), color = MaterialTheme.colorScheme.onSurface, modifier = Modifier.fillMaxWidth(), - textAlign = TextAlign.Center - ) + textAlign = TextAlign.Center) Gap(Size.tiny) TextButton( onClick = { openMergeSource(isMergedManga.url, isMergedManga.title) }, - modifier = Modifier.fillMaxWidth() - ) { - Text( - text = stringResource(id = R.string.open_merged_in_webview), - color = themeColorState.buttonColor - ) - } + modifier = Modifier.fillMaxWidth()) { + Text( + text = stringResource(id = R.string.open_merged_in_webview), + color = themeColorState.buttonColor) + } Gap(Size.tiny) TextButton( onClick = { removeMergeSource(isMergedManga.mergeType) }, - modifier = Modifier.fillMaxWidth() - ) { - Text( - text = stringResource(id = R.string.remove_merged_source), - color = themeColorState.buttonColor - ) - } + modifier = Modifier.fillMaxWidth()) { + Text( + text = stringResource(id = R.string.remove_merged_source), + color = themeColorState.buttonColor) + } Gap(Size.tiny) } } @@ -150,8 +145,7 @@ fun MergeSheet( SuccessResults( mergeMangaList = mergeSearchResults.mergeMangaList, mergeType = mergeType!!, - mergeMangaClick = mergeMangaClick - ) + mergeMangaClick = mergeMangaClick) } NonSuccessResultsAndChips( themeColorState = themeColorState, @@ -207,11 +201,7 @@ private fun SuccessResults( modifier = Modifier.fillMaxWidth(), contentPadding = PaddingValues( - top = 16.dp, - bottom = Size.huge * 2, - start = Size.small, - end = Size.small - ), + top = 16.dp, bottom = Size.huge * 2, start = Size.small, end = Size.small), verticalArrangement = Arrangement.spacedBy(Size.small), horizontalArrangement = Arrangement.spacedBy(Size.small), ) { @@ -258,8 +248,7 @@ private fun SuccessResults( color = Color.White, style = MaterialTheme.typography.bodyMedium.copy( - fontWeight = FontWeight.Medium - ), + fontWeight = FontWeight.Medium), ) } } @@ -283,9 +272,7 @@ private fun BoxScope.NonSuccessResultsAndChips( when (searchResults) { is MergeSearchResult.Loading -> CircularProgressIndicator( - color = themeColorState.buttonColor, - modifier = Modifier.size(32.dp) - ) + color = themeColorState.buttonColor, modifier = Modifier.size(32.dp)) is MergeSearchResult.NoResult -> Text(text = stringResource(id = R.string.no_results_found)) is MergeSearchResult.Error -> Text(text = searchResults.errorMessage) @@ -311,8 +298,7 @@ private fun BoxScope.NonSuccessResultsAndChips( }, colors = SuggestionChipDefaults.elevatedSuggestionChipColors( - containerColor = themeColorState.buttonColor - ), + containerColor = themeColorState.buttonColor), ) } } diff --git a/app/src/main/java/org/nekomanga/presentation/components/sheets/TrackingDateSheet.kt b/app/src/main/java/org/nekomanga/presentation/components/sheets/TrackingDateSheet.kt index e3321f4c43..2cb9feb541 100644 --- a/app/src/main/java/org/nekomanga/presentation/components/sheets/TrackingDateSheet.kt +++ b/app/src/main/java/org/nekomanga/presentation/components/sheets/TrackingDateSheet.kt @@ -98,8 +98,7 @@ fun TrackingDateSheet( ), style = MaterialTheme.typography.titleLarge.copy( - color = MaterialTheme.colorScheme.onSurface - ), + color = MaterialTheme.colorScheme.onSurface), textAlign = TextAlign.Center, modifier = Modifier.fillMaxWidth().align(Alignment.CenterStart), ) @@ -114,15 +113,12 @@ fun TrackingDateSheet( text = stringResource( id = R.string.current_date_, - trackingDate.dateFormat.format(trackingDate.currentDate) - ), + trackingDate.dateFormat.format(trackingDate.currentDate)), style = MaterialTheme.typography.titleSmall.copy( color = MaterialTheme.colorScheme.onSurface.copy( - alpha = NekoColors.mediumAlphaHighContrast - ) - ), + alpha = NekoColors.mediumAlphaHighContrast)), textAlign = TextAlign.Center, modifier = Modifier.fillMaxWidth(), ) @@ -130,17 +126,15 @@ fun TrackingDateSheet( TextButton( onClick = { trackDateChanged(RemoveTrackingDate(trackingDate.readingDate, trackAndService)) + }) { + Text( + text = stringResource(id = R.string.remove), + style = + MaterialTheme.typography.titleMedium.copy( + color = themeColorState.buttonColor), + modifier = Modifier.fillMaxWidth(), + ) } - ) { - Text( - text = stringResource(id = R.string.remove), - style = - MaterialTheme.typography.titleMedium.copy( - color = themeColorState.buttonColor - ), - modifier = Modifier.fillMaxWidth(), - ) - } } else { showDateField = true } @@ -154,15 +148,11 @@ fun TrackingDateSheet( if (suggestedDateEpoch != null && suggestedDateEpoch != 0L) { val suggestedDate = LocalDateTime.ofInstant( - Instant.ofEpochMilli(suggestedDateEpoch), - ZoneId.systemDefault() - ) + Instant.ofEpochMilli(suggestedDateEpoch), ZoneId.systemDefault()) .toLocalDate() val currentDate = LocalDateTime.ofInstant( - Instant.ofEpochMilli(trackingDate.currentDate), - ZoneId.systemDefault() - ) + Instant.ofEpochMilli(trackingDate.currentDate), ZoneId.systemDefault()) .toLocalDate() if ((suggestedDate.atStartOfDay() != currentDate.atStartOfDay())) { @@ -171,26 +161,19 @@ fun TrackingDateSheet( onClick = { trackDateChanged( EditTrackingDate( - trackingDate.readingDate, - suggestedDate, - trackAndService - ) + trackingDate.readingDate, suggestedDate, trackAndService)) + }) { + Text( + text = + stringResource( + id = R.string.use_suggested_date_of_, + suggestedDate.format(dateTimeFormatter)), + style = + MaterialTheme.typography.titleMedium.copy( + color = themeColorState.buttonColor), + modifier = Modifier.fillMaxWidth(), ) } - ) { - Text( - text = - stringResource( - id = R.string.use_suggested_date_of_, - suggestedDate.format(dateTimeFormatter) - ), - style = - MaterialTheme.typography.titleMedium.copy( - color = themeColorState.buttonColor - ), - modifier = Modifier.fillMaxWidth(), - ) - } } } @@ -201,8 +184,7 @@ fun TrackingDateSheet( text = stringResource(id = R.string.edit), style = MaterialTheme.typography.titleMedium.copy( - color = themeColorState.buttonColor - ), + color = themeColorState.buttonColor), modifier = Modifier.fillMaxWidth(), ) } @@ -228,29 +210,24 @@ fun TrackingDateSheet( maxDate = LocalDate.now(), textStyle = MaterialTheme.typography.headlineSmall.copy( - color = MaterialTheme.colorScheme.onSurface - ), + color = MaterialTheme.colorScheme.onSurface), cursorBrush = SolidColor(themeColorState.buttonColor), hintTextStyle = MaterialTheme.typography.headlineSmall.copy( color = MaterialTheme.colorScheme.onSurface.copy( - alpha = NekoColors.disabledAlphaHighContrast - ) - ), + alpha = NekoColors.disabledAlphaHighContrast)), delimiterSpacing = Size.extraExtraTiny, ) ElevatedButton( onClick = { trackDateChanged( - EditTrackingDate(trackingDate.readingDate, newDate!!, trackAndService) - ) + EditTrackingDate(trackingDate.readingDate, newDate!!, trackAndService)) }, colors = ButtonDefaults.elevatedButtonColors( containerColor = themeColorState.buttonColor, - contentColor = MaterialTheme.colorScheme.surface - ), + contentColor = MaterialTheme.colorScheme.surface), enabled = newDate != null, ) { Text(text = stringResource(id = android.R.string.ok)) diff --git a/app/src/main/java/org/nekomanga/presentation/components/sheets/TrackingSearchSheet.kt b/app/src/main/java/org/nekomanga/presentation/components/sheets/TrackingSearchSheet.kt index eea372fc52..b93649e5a9 100644 --- a/app/src/main/java/org/nekomanga/presentation/components/sheets/TrackingSearchSheet.kt +++ b/app/src/main/java/org/nekomanga/presentation/components/sheets/TrackingSearchSheet.kt @@ -86,10 +86,8 @@ fun TrackingSearchSheet( verticalArrangement = Arrangement.spacedBy(12.dp), ) { item { Gap(Size.tiny) } - if ( - alreadySelectedTrack == null && - trackSearchResult.trackSearchResult.size == 1 - ) { + if (alreadySelectedTrack == null && + trackSearchResult.trackSearchResult.size == 1) { trackSearchItemClick(trackSearchResult.trackSearchResult.first()) } @@ -129,9 +127,7 @@ fun TrackingSearchSheet( } else -> CenteredBox( - themeColorState = themeColorState, - trackSearchResult = trackSearchResult - ) + themeColorState = themeColorState, trackSearchResult = trackSearchResult) } var searchText by remember { mutableStateOf(title) } SearchFooter( @@ -139,8 +135,7 @@ fun TrackingSearchSheet( labelText = stringResource(id = R.string.title), title = searchText, textChanged = { searchText = it }, - search = searchTracker - ) + search = searchTracker) } } } @@ -154,14 +149,11 @@ private fun CenteredBox(themeColorState: ThemeColorState, trackSearchResult: Tra when (trackSearchResult) { is TrackSearchResult.Loading -> CircularProgressIndicator( - color = themeColorState.buttonColor, - modifier = Modifier.size(32.dp) - ) + color = themeColorState.buttonColor, modifier = Modifier.size(32.dp)) is TrackSearchResult.NoResult -> Text( text = stringResource(id = R.string.no_results_found), - color = MaterialTheme.colorScheme.onSurface - ) + color = MaterialTheme.colorScheme.onSurface) is TrackSearchResult.Error -> Text(text = trackSearchResult.errorMessage) else -> Unit } @@ -209,15 +201,12 @@ private fun TrackSearchItem( Modifier.height(IntrinsicSize.Min) .fillMaxWidth() .background( - color = backdropColor.copy(alpha = NekoColors.highAlphaLowContrast) - ), + color = backdropColor.copy(alpha = NekoColors.highAlphaLowContrast)), ) { IconButton( onClick = { openInBrowser( - trackSearch.trackItem.trackingUrl, - trackSearch.trackItem.title - ) + trackSearch.trackItem.trackingUrl, trackSearch.trackItem.title) }, modifier = Modifier.padding(horizontal = Size.tiny).align(Alignment.TopEnd), ) { @@ -236,8 +225,7 @@ private fun TrackSearchItem( text = trackSearch.trackItem.title, style = MaterialTheme.typography.titleLarge.copy( - fontWeight = FontWeight.SemiBold - ), + fontWeight = FontWeight.SemiBold), modifier = Modifier.fillMaxWidth(.9f), color = MaterialTheme.colorScheme.onSurface, ) @@ -248,8 +236,7 @@ private fun TrackSearchItem( text = stringResource(id = R.string.type), style = MaterialTheme.typography.bodyLarge.copy( - fontWeight = FontWeight.Medium - ), + fontWeight = FontWeight.Medium), color = MaterialTheme.colorScheme.onSurface, ) Gap(Size.tiny) @@ -257,8 +244,7 @@ private fun TrackSearchItem( text = trackSearch.publishingType, color = MaterialTheme.colorScheme.onSurface.copy( - alpha = NekoColors.mediumAlphaHighContrast - ), + alpha = NekoColors.mediumAlphaHighContrast), style = MaterialTheme.typography.bodyLarge, ) } @@ -270,16 +256,13 @@ private fun TrackSearchItem( text = stringResource(id = R.string.started), style = MaterialTheme.typography.bodyLarge.copy( - fontWeight = FontWeight.Medium - ) - ) + fontWeight = FontWeight.Medium)) Gap(Size.tiny) Text( text = trackSearch.startDate, color = MaterialTheme.colorScheme.onSurface.copy( - alpha = NekoColors.mediumAlphaHighContrast - ), + alpha = NekoColors.mediumAlphaHighContrast), style = MaterialTheme.typography.bodyLarge, ) } @@ -297,8 +280,7 @@ private fun TrackSearchItem( overflow = TextOverflow.Ellipsis, color = MaterialTheme.colorScheme.onSurface.copy( - alpha = NekoColors.mediumAlphaHighContrast - ), + alpha = NekoColors.mediumAlphaHighContrast), style = MaterialTheme.typography.bodyLarge, ) } diff --git a/app/src/main/java/org/nekomanga/presentation/components/sheets/TrackingSheet.kt b/app/src/main/java/org/nekomanga/presentation/components/sheets/TrackingSheet.kt index a10058d7c8..f7c76cc796 100644 --- a/app/src/main/java/org/nekomanga/presentation/components/sheets/TrackingSheet.kt +++ b/app/src/main/java/org/nekomanga/presentation/components/sheets/TrackingSheet.kt @@ -132,8 +132,7 @@ fun TrackingSheet( TrackingDate( readingDate = ReadingDate.Start, currentDate = trackAndService.track.startedReadingDate, - dateFormat = dateFormat - ), + dateFormat = dateFormat), ) } else if (calendarFinishedTrackDialog is ShowDialog) { val trackAndService = (calendarFinishedTrackDialog as ShowDialog).trackAndService @@ -142,58 +141,57 @@ fun TrackingSheet( TrackingDate( readingDate = ReadingDate.Finish, trackAndService.track.finishedReadingDate, - dateFormat = dateFormat - ) - ) + dateFormat = dateFormat)) } LazyColumn( modifier = Modifier.fillMaxWidth(), - verticalArrangement = Arrangement.spacedBy(Size.small) - ) { - items(servicesProvider()) { service -> - val track = tracksProvider().firstOrNull { it.trackServiceId == service.id } + verticalArrangement = Arrangement.spacedBy(Size.small)) { + items(servicesProvider()) { service -> + val track = tracksProvider().firstOrNull { it.trackServiceId == service.id } - val trackAndService = - when (track != null) { - true -> TrackAndService(track, service) - false -> null - } - TrackingServiceItem( - themeColor = themeColor, - inLibrary = inLibrary, - service = service, - trackAndService = trackAndService, - dateFormat = dateFormat, - onLogoClick = onLogoClick, - onSearchTrackClick = { clickTracked -> - onSearchTrackClick(service, clickTracked) - }, - onRemoveTrackClick = { - trackAndService?.run { removeTrackDialog = ShowDialog(trackAndService) } - }, - statusClick = { - trackAndService?.run { statusDialog = ShowDialog(trackAndService) } - }, - scoreClick = { - trackAndService?.run { scoreDialog = ShowDialog(trackAndService) } - }, - chapterClick = { - trackAndService?.run { chapterTrackDialog = ShowDialog(trackAndService) } - }, - startDateClick = { - trackAndService?.run { - calendarStartTrackDialog = ShowDialog(trackAndService) - } - }, - finishDateClick = { - trackAndService?.run { - calendarFinishedTrackDialog = ShowDialog(trackAndService) + val trackAndService = + when (track != null) { + true -> TrackAndService(track, service) + false -> null } - }, - ) + TrackingServiceItem( + themeColor = themeColor, + inLibrary = inLibrary, + service = service, + trackAndService = trackAndService, + dateFormat = dateFormat, + onLogoClick = onLogoClick, + onSearchTrackClick = { clickTracked -> + onSearchTrackClick(service, clickTracked) + }, + onRemoveTrackClick = { + trackAndService?.run { removeTrackDialog = ShowDialog(trackAndService) } + }, + statusClick = { + trackAndService?.run { statusDialog = ShowDialog(trackAndService) } + }, + scoreClick = { + trackAndService?.run { scoreDialog = ShowDialog(trackAndService) } + }, + chapterClick = { + trackAndService?.run { + chapterTrackDialog = ShowDialog(trackAndService) + } + }, + startDateClick = { + trackAndService?.run { + calendarStartTrackDialog = ShowDialog(trackAndService) + } + }, + finishDateClick = { + trackAndService?.run { + calendarFinishedTrackDialog = ShowDialog(trackAndService) + } + }, + ) + } } - } } } @@ -225,9 +223,7 @@ private fun TrackingServiceItem( BorderStroke( 1.dp, MaterialTheme.colorScheme.onSurface.copy( - alpha = NekoColors.disabledAlphaLowContrast - ) - ), + alpha = NekoColors.disabledAlphaLowContrast)), modifier = Modifier.padding(horizontal = Size.small), ) { Column(modifier = Modifier.fillMaxSize()) { @@ -251,16 +247,14 @@ private fun TrackingServiceItem( service = trackAndService.service, statusClick, scoreClick, - chapterClick - ) + chapterClick) if (service.supportsReadingDates) { Divider() TrackRowThree( track = trackAndService.track, dateFormat = dateFormat, startDateClick = startDateClick, - finishDateClick = finishDateClick - ) + finishDateClick = finishDateClick) } } } @@ -284,8 +278,7 @@ private fun NoTrack( text = stringResource(id = R.string.add_tracking), color = themeColor.buttonColor, textAlign = TextAlign.Center, - modifier = Modifier.fillMaxWidth() - ) + modifier = Modifier.fillMaxWidth()) } } @@ -386,8 +379,7 @@ private fun TrackRowTwo( Text( text = chapterText, style = MaterialTheme.typography.bodyMedium.copy(letterSpacing = (-.3f).sp), - color = MaterialTheme.colorScheme.onSurface - ) + color = MaterialTheme.colorScheme.onSurface) } VerticalDivider() } @@ -400,8 +392,7 @@ private fun TrackRowTwo( stringResource(id = R.string.score), color = MaterialTheme.colorScheme.onSurface.copy( - alpha = NekoColors.disabledAlphaHighContrast - ), + alpha = NekoColors.disabledAlphaHighContrast), style = MaterialTheme.typography.bodyMedium, ) Icon( @@ -410,8 +401,7 @@ private fun TrackRowTwo( modifier = Modifier.size(12.dp), tint = MaterialTheme.colorScheme.onSurface.copy( - alpha = NekoColors.disabledAlphaHighContrast - ), + alpha = NekoColors.disabledAlphaHighContrast), ) } } @@ -443,8 +433,7 @@ fun TrackRowThree( false -> stringResource(id = R.string.started_reading_date) to MaterialTheme.colorScheme.onSurface.copy( - alpha = NekoColors.disabledAlphaHighContrast - ) + alpha = NekoColors.disabledAlphaHighContrast) } Text(text = startText, color = startColor, style = MaterialTheme.typography.bodyMedium) } @@ -460,8 +449,7 @@ fun TrackRowThree( false -> stringResource(id = R.string.finished_reading_date) to MaterialTheme.colorScheme.onSurface.copy( - alpha = NekoColors.disabledAlphaHighContrast - ) + alpha = NekoColors.disabledAlphaHighContrast) } Text(text = endText, color = endColor, style = MaterialTheme.typography.bodyMedium) } @@ -483,8 +471,7 @@ private fun Logo(service: TrackServiceItem, track: TrackItem?, onClick: (String, Image( painter = painterResource(id = service.logoRes), contentDescription = null, - modifier = Modifier.align(Alignment.Center) - ) + modifier = Modifier.align(Alignment.Center)) } } diff --git a/app/src/main/java/org/nekomanga/presentation/components/snackbar/Snackbar.kt b/app/src/main/java/org/nekomanga/presentation/components/snackbar/Snackbar.kt index 6f93575524..3c17c29bb1 100644 --- a/app/src/main/java/org/nekomanga/presentation/components/snackbar/Snackbar.kt +++ b/app/src/main/java/org/nekomanga/presentation/components/snackbar/Snackbar.kt @@ -34,8 +34,7 @@ fun snackbarHost( color = actionColor ?: MaterialTheme.colorScheme.onSurface, style = MaterialTheme.typography.labelLarge.copy( - fontWeight = FontWeight.Medium - ), + fontWeight = FontWeight.Medium), ) } } diff --git a/app/src/main/java/org/nekomanga/presentation/components/theme/ThemeItem.kt b/app/src/main/java/org/nekomanga/presentation/components/theme/ThemeItem.kt index b18cb30a2a..7693739ebb 100644 --- a/app/src/main/java/org/nekomanga/presentation/components/theme/ThemeItem.kt +++ b/app/src/main/java/org/nekomanga/presentation/components/theme/ThemeItem.kt @@ -76,13 +76,11 @@ fun ThemeItem(theme: Themes, isDarkTheme: Boolean, selected: Boolean, onClick: ( selected, selectedColor = MaterialTheme.colorScheme.primary, themeMatchesApp, - onClick - ) + onClick) Text( text = stringResource(id = if (isDarkTheme) theme.darkNameRes else theme.nameRes), textAlign = TextAlign.Center, - style = MaterialTheme.typography.bodySmall - ) + style = MaterialTheme.typography.bodySmall) } } @@ -106,121 +104,118 @@ fun AppThemePreviewItem( onClick = onClick, modifier = Modifier.height(180.dp).fillMaxWidth(), colors = CardDefaults.outlinedCardColors(containerColor = colorScheme.background), - border = BorderStroke(width = Size.tiny, color = selectedColor) - ) { - // App Bar - Row( - modifier = Modifier.fillMaxWidth().height(40.dp).padding(Size.small), - verticalAlignment = Alignment.CenterVertically, - ) { - Box( - modifier = - Modifier.fillMaxHeight(0.8f) - .weight(0.7f) - .padding(end = Size.small) - .background( - color = colorScheme.surfaceVariant, - shape = MaterialTheme.shapes.small, - ), - ) - - Box( - modifier = Modifier.weight(0.3f), - contentAlignment = Alignment.CenterEnd, - ) { - if (selected) { - Icon( - imageVector = Icons.Filled.CheckCircle, - contentDescription = stringResource(R.string.selected), - tint = selectedColor, - ) - } - } - } - - // Cover - Box( - modifier = - Modifier.padding(start = Size.small, top = Size.extraTiny) - .background( - color = DividerDefaults.color, - shape = MaterialTheme.shapes.small, - ) - .fillMaxWidth(0.5f) - .aspectRatio(MangaCover.Book.ratio), - ) { + border = BorderStroke(width = Size.tiny, color = selectedColor)) { + // App Bar Row( - modifier = - Modifier.padding(Size.small) - .size(width = Size.large, height = Size.medium) - .clip(RoundedCornerShape(Size.small)), + modifier = Modifier.fillMaxWidth().height(40.dp).padding(Size.small), + verticalAlignment = Alignment.CenterVertically, ) { Box( modifier = - Modifier.fillMaxHeight() - .width(Size.smedium) - .background(colorScheme.tertiary), + Modifier.fillMaxHeight(0.8f) + .weight(0.7f) + .padding(end = Size.small) + .background( + color = colorScheme.surfaceVariant, + shape = MaterialTheme.shapes.small, + ), ) + Box( - modifier = - Modifier.fillMaxHeight() - .width(Size.smedium) - .background(colorScheme.secondary), - ) + modifier = Modifier.weight(0.3f), + contentAlignment = Alignment.CenterEnd, + ) { + if (selected) { + Icon( + imageVector = Icons.Filled.CheckCircle, + contentDescription = stringResource(R.string.selected), + tint = selectedColor, + ) + } + } } - } - // Bottom bar - Box( - modifier = Modifier.fillMaxWidth().weight(1f), - contentAlignment = Alignment.BottomCenter, - ) { - Surface( - tonalElevation = Size.small, + // Cover + Box( + modifier = + Modifier.padding(start = Size.small, top = Size.extraTiny) + .background( + color = DividerDefaults.color, + shape = MaterialTheme.shapes.small, + ) + .fillMaxWidth(0.5f) + .aspectRatio(MangaCover.Book.ratio), ) { Row( modifier = - Modifier.height(Size.extraLarge) - .fillMaxWidth() - .background(colorScheme.surfaceVariant) - .padding(horizontal = Size.small), - horizontalArrangement = Arrangement.SpaceEvenly, - verticalAlignment = Alignment.CenterVertically, + Modifier.padding(Size.small) + .size(width = Size.large, height = Size.medium) + .clip(RoundedCornerShape(Size.small)), ) { Box( modifier = - Modifier.size(Size.medium) - .background( - color = - colorScheme.onSurface.copy( - alpha = NekoColors.mediumAlphaHighContrast - ), - shape = CircleShape, - ), + Modifier.fillMaxHeight() + .width(Size.smedium) + .background(colorScheme.tertiary), ) Box( modifier = - Modifier.size(Size.medium) - .background( - color = colorScheme.primary, - shape = CircleShape, - ), + Modifier.fillMaxHeight() + .width(Size.smedium) + .background(colorScheme.secondary), ) - Box( + } + } + + // Bottom bar + Box( + modifier = Modifier.fillMaxWidth().weight(1f), + contentAlignment = Alignment.BottomCenter, + ) { + Surface( + tonalElevation = Size.small, + ) { + Row( modifier = - Modifier.size(Size.medium) - .background( - color = - colorScheme.onSurface.copy( - alpha = NekoColors.mediumAlphaHighContrast - ), - shape = CircleShape, - ), - ) + Modifier.height(Size.extraLarge) + .fillMaxWidth() + .background(colorScheme.surfaceVariant) + .padding(horizontal = Size.small), + horizontalArrangement = Arrangement.SpaceEvenly, + verticalAlignment = Alignment.CenterVertically, + ) { + Box( + modifier = + Modifier.size(Size.medium) + .background( + color = + colorScheme.onSurface.copy( + alpha = NekoColors.mediumAlphaHighContrast), + shape = CircleShape, + ), + ) + Box( + modifier = + Modifier.size(Size.medium) + .background( + color = colorScheme.primary, + shape = CircleShape, + ), + ) + Box( + modifier = + Modifier.size(Size.medium) + .background( + color = + colorScheme.onSurface.copy( + alpha = NekoColors.mediumAlphaHighContrast), + shape = CircleShape, + ), + ) + } } } } - } } @Preview diff --git a/app/src/main/java/org/nekomanga/presentation/screens/AboutScreen.kt b/app/src/main/java/org/nekomanga/presentation/screens/AboutScreen.kt index 4c15c7b052..d44700ce7e 100644 --- a/app/src/main/java/org/nekomanga/presentation/screens/AboutScreen.kt +++ b/app/src/main/java/org/nekomanga/presentation/screens/AboutScreen.kt @@ -87,10 +87,8 @@ fun AboutScreen( } } - if ( - aboutScreenState.value.shouldShowUpdateDialog && - aboutScreenState.value.updateResult is AppUpdateResult.NewUpdate - ) { + if (aboutScreenState.value.shouldShowUpdateDialog && + aboutScreenState.value.updateResult is AppUpdateResult.NewUpdate) { AppUpdateDialog( release = (aboutScreenState.value.updateResult as AppUpdateResult.NewUpdate).release, diff --git a/app/src/main/java/org/nekomanga/presentation/screens/BrowseScreen.kt b/app/src/main/java/org/nekomanga/presentation/screens/BrowseScreen.kt index a99b1b466c..18161ba57a 100644 --- a/app/src/main/java/org/nekomanga/presentation/screens/BrowseScreen.kt +++ b/app/src/main/java/org/nekomanga/presentation/screens/BrowseScreen.kt @@ -175,10 +175,8 @@ fun BrowseScreen( actions = { AppBarActions( actions = - when ( - browseScreenType != BrowseScreenType.Homepage && - browseScreenType != BrowseScreenType.Other - ) { + when (browseScreenType != BrowseScreenType.Homepage && + browseScreenType != BrowseScreenType.Other) { true -> listOf( listGridAppBarAction( @@ -421,8 +419,7 @@ private fun FooterFilterChip( label = { Text( text = name, - style = MaterialTheme.typography.labelLarge.copy(fontWeight = FontWeight.Medium) - ) + style = MaterialTheme.typography.labelLarge.copy(fontWeight = FontWeight.Medium)) }, colors = FilterChipDefaults.filterChipColors( diff --git a/app/src/main/java/org/nekomanga/presentation/screens/CrashScreen.kt b/app/src/main/java/org/nekomanga/presentation/screens/CrashScreen.kt index 49c90996bb..44ccf77b29 100644 --- a/app/src/main/java/org/nekomanga/presentation/screens/CrashScreen.kt +++ b/app/src/main/java/org/nekomanga/presentation/screens/CrashScreen.kt @@ -91,9 +91,7 @@ fun CrashScreen( Text( text = stringResource( - R.string.crash_screen_description, - stringResource(id = R.string.app_name) - ), + R.string.crash_screen_description, stringResource(id = R.string.app_name)), modifier = Modifier.padding(horizontal = Size.medium), ) Box( diff --git a/app/src/main/java/org/nekomanga/presentation/screens/DisplayScreen.kt b/app/src/main/java/org/nekomanga/presentation/screens/DisplayScreen.kt index 37433e8957..6a7dd317cb 100644 --- a/app/src/main/java/org/nekomanga/presentation/screens/DisplayScreen.kt +++ b/app/src/main/java/org/nekomanga/presentation/screens/DisplayScreen.kt @@ -193,8 +193,7 @@ fun DisplayScreen( modifier = Modifier.padding( bottom = - contentPadding.calculateBottomPadding() + Size.small - ) + contentPadding.calculateBottomPadding() + Size.small) .align(Alignment.BottomCenter) .fillMaxWidth(), ) diff --git a/app/src/main/java/org/nekomanga/presentation/screens/MangaScreen.kt b/app/src/main/java/org/nekomanga/presentation/screens/MangaScreen.kt index c09100f3eb..372aec16e3 100644 --- a/app/src/main/java/org/nekomanga/presentation/screens/MangaScreen.kt +++ b/app/src/main/java/org/nekomanga/presentation/screens/MangaScreen.kt @@ -225,8 +225,7 @@ fun MangaScreen( actions = { OverflowOptions( chapterActions = chapterActions, - chaptersProvider = { generalState.value.activeChapters } - ) + chaptersProvider = { generalState.value.activeChapters }) }, ) { incomingPaddingValues -> PullRefresh( @@ -257,120 +256,117 @@ fun MangaScreen( CompositionLocalProvider( LocalRippleTheme provides themeColorState.rippleTheme, - LocalTextSelectionColors provides themeColorState.textSelectionColors - ) { - if ( - windowSizeClass.widthSizeClass == WindowWidthSizeClass.Expanded && - !generalState.value.forcePortrait - ) { - SideBySideLayout( - mangaDetailContentPadding = mangaDetailContentPadding, - chapterContentPadding = chapterContentPadding, - details = { - Details( - themeColorState = themeColorState, - mangaState = mangaState, - generalState = generalState, - isSearching = isSearching, - trackMergeState = trackMergeState, - windowSizeClass = windowSizeClass, - chapterActions = chapterActions, - categoryActions = categoryActions, - descriptionActions = descriptionActions, - informationActions = informationActions, - generatePalette = generatePalette, - openSheet = { sheet -> openSheet(sheet) }, - similarClick = similarClick, - shareClick = shareClick, - toggleFavorite = toggleFavorite, - ) - }, - chapterHeader = { - ChapterHeader( - themeColorState = themeColorState, - isSearching = isSearching, - generalState = generalState, - openSheet = { sheet -> openSheet(sheet) }, - ) - }, - chaptersProvider = { - when (isSearching.value) { - true -> generalState.value.searchChapters - false -> generalState.value.activeChapters - } - }, - chapterRow = { index, chapterItem -> - ChapterRow( - themeColorState = themeColorState, - generalState = generalState, - chapterActions = chapterActions, - scope = scope, - chapterItem = chapterItem, - index = index, - ) - }, - ) - } else { - VerticalLayout( - contentPadding = mangaDetailContentPadding, - details = { - Details( - themeColorState = themeColorState, - mangaState = mangaState, - generalState = generalState, - isSearching = isSearching, - trackMergeState = trackMergeState, - windowSizeClass = windowSizeClass, - chapterActions = chapterActions, - categoryActions = categoryActions, - descriptionActions = descriptionActions, - informationActions = informationActions, - generatePalette = generatePalette, - openSheet = { sheet -> openSheet(sheet) }, - similarClick = similarClick, - shareClick = shareClick, - toggleFavorite = toggleFavorite, - ) - }, - chapterHeader = { - ChapterHeader( - themeColorState = themeColorState, - isSearching = isSearching, - generalState = generalState, - openSheet = { sheet -> openSheet(sheet) }, - ) - }, - chaptersProvider = { - when (isSearching.value) { - true -> generalState.value.searchChapters - false -> generalState.value.activeChapters - } - }, - chapterRow = { index, chapterItem -> - ChapterRow( - themeColorState = themeColorState, - generalState = generalState, - chapterActions = chapterActions, - scope = scope, - chapterItem = chapterItem, - index = index, - ) - }, - ) - } + LocalTextSelectionColors provides themeColorState.textSelectionColors) { + if (windowSizeClass.widthSizeClass == WindowWidthSizeClass.Expanded && + !generalState.value.forcePortrait) { + SideBySideLayout( + mangaDetailContentPadding = mangaDetailContentPadding, + chapterContentPadding = chapterContentPadding, + details = { + Details( + themeColorState = themeColorState, + mangaState = mangaState, + generalState = generalState, + isSearching = isSearching, + trackMergeState = trackMergeState, + windowSizeClass = windowSizeClass, + chapterActions = chapterActions, + categoryActions = categoryActions, + descriptionActions = descriptionActions, + informationActions = informationActions, + generatePalette = generatePalette, + openSheet = { sheet -> openSheet(sheet) }, + similarClick = similarClick, + shareClick = shareClick, + toggleFavorite = toggleFavorite, + ) + }, + chapterHeader = { + ChapterHeader( + themeColorState = themeColorState, + isSearching = isSearching, + generalState = generalState, + openSheet = { sheet -> openSheet(sheet) }, + ) + }, + chaptersProvider = { + when (isSearching.value) { + true -> generalState.value.searchChapters + false -> generalState.value.activeChapters + } + }, + chapterRow = { index, chapterItem -> + ChapterRow( + themeColorState = themeColorState, + generalState = generalState, + chapterActions = chapterActions, + scope = scope, + chapterItem = chapterItem, + index = index, + ) + }, + ) + } else { + VerticalLayout( + contentPadding = mangaDetailContentPadding, + details = { + Details( + themeColorState = themeColorState, + mangaState = mangaState, + generalState = generalState, + isSearching = isSearching, + trackMergeState = trackMergeState, + windowSizeClass = windowSizeClass, + chapterActions = chapterActions, + categoryActions = categoryActions, + descriptionActions = descriptionActions, + informationActions = informationActions, + generatePalette = generatePalette, + openSheet = { sheet -> openSheet(sheet) }, + similarClick = similarClick, + shareClick = shareClick, + toggleFavorite = toggleFavorite, + ) + }, + chapterHeader = { + ChapterHeader( + themeColorState = themeColorState, + isSearching = isSearching, + generalState = generalState, + openSheet = { sheet -> openSheet(sheet) }, + ) + }, + chaptersProvider = { + when (isSearching.value) { + true -> generalState.value.searchChapters + false -> generalState.value.activeChapters + } + }, + chapterRow = { index, chapterItem -> + ChapterRow( + themeColorState = themeColorState, + generalState = generalState, + chapterActions = chapterActions, + scope = scope, + chapterItem = chapterItem, + index = index, + ) + }, + ) + } - if (generalState.value.removedChapters.isNotEmpty()) { - RemovedChaptersDialog( - themeColorState = themeColorState, - chapters = generalState.value.removedChapters, - onConfirm = { - chapterActions.delete(generalState.value.removedChapters) - chapterActions.clearRemoved - }, - onDismiss = chapterActions.clearRemoved, - ) + if (generalState.value.removedChapters.isNotEmpty()) { + RemovedChaptersDialog( + themeColorState = themeColorState, + chapters = generalState.value.removedChapters, + onConfirm = { + chapterActions.delete(generalState.value.removedChapters) + chapterActions.clearRemoved + }, + onDismiss = chapterActions.clearRemoved, + ) + } } - } } } } @@ -628,8 +624,6 @@ fun defaultThemeColorState(): ThemeColorState { ColorUtils.blendARGB( MaterialTheme.colorScheme.secondary.toArgb(), MaterialTheme.colorScheme.surface.toArgb(), - .706f - ) - ), + .706f)), ) } diff --git a/app/src/main/java/org/nekomanga/presentation/screens/SimilarScreen.kt b/app/src/main/java/org/nekomanga/presentation/screens/SimilarScreen.kt index 402c4e7de4..12f5f9a044 100644 --- a/app/src/main/java/org/nekomanga/presentation/screens/SimilarScreen.kt +++ b/app/src/main/java/org/nekomanga/presentation/screens/SimilarScreen.kt @@ -117,9 +117,8 @@ fun SimilarScreen( mangaClick = mangaClick, mangaLongClick = { displayManga: DisplayManga -> haptic.performHapticFeedback(HapticFeedbackType.LongPress) - if ( - !displayManga.inLibrary && similarScreenState.value.promptForCategories - ) { + if (!displayManga.inLibrary && + similarScreenState.value.promptForCategories) { scope.launch { longClickedMangaId = displayManga.mangaId sheetState.show() diff --git a/app/src/main/java/org/nekomanga/presentation/screens/StatsScreen.kt b/app/src/main/java/org/nekomanga/presentation/screens/StatsScreen.kt index ee2f5aefef..ec71b7c9a1 100644 --- a/app/src/main/java/org/nekomanga/presentation/screens/StatsScreen.kt +++ b/app/src/main/java/org/nekomanga/presentation/screens/StatsScreen.kt @@ -91,10 +91,8 @@ fun StatsScreen( } }, ) { incomingPaddingValues -> - if ( - statsState.value.screenState is Loading || - (statsState.value.screenState is Detailed && detailedState.value.isLoading) - ) { + if (statsState.value.screenState is Loading || + (statsState.value.screenState is Detailed && detailedState.value.isLoading)) { LoadingScreen(incomingPaddingValues) } else if (statsState.value.screenState is StatsConstants.ScreenState.NoResults) { Box( @@ -103,30 +101,26 @@ fun StatsScreen( .padding( top = incomingPaddingValues.calculateTopPadding(), start = 16.dp, - end = 16.dp - ), + end = 16.dp), contentAlignment = Alignment.BottomCenter, ) { EmptyScreen( iconicImage = CommunityMaterial.Icon2.cmd_heart_off, iconSize = 128.dp, - message = stringResource(id = R.string.unable_to_generate_stats) - ) + message = stringResource(id = R.string.unable_to_generate_stats)) } } else { if (isSimple) { SimpleStats( statsState = statsState.value, contentPadding = incomingPaddingValues, - windowSizeClass = windowSizeClass - ) + windowSizeClass = windowSizeClass) } else { DetailedStats( detailedStats = detailedState.value, colors = colors, contentPadding = incomingPaddingValues, - windowSizeClass = windowSizeClass - ) + windowSizeClass = windowSizeClass) } } } diff --git a/app/src/main/java/org/nekomanga/presentation/screens/WebViewScreen.kt b/app/src/main/java/org/nekomanga/presentation/screens/WebViewScreen.kt index f58a70a18a..8cfb40c909 100644 --- a/app/src/main/java/org/nekomanga/presentation/screens/WebViewScreen.kt +++ b/app/src/main/java/org/nekomanga/presentation/screens/WebViewScreen.kt @@ -93,11 +93,9 @@ fun WebViewScreen( ), ) + listOf( - if ( - navigator.canGoBack && - state.lastLoadedUrl != null && - canOpenInApp(state.lastLoadedUrl!!) - ) { + if (navigator.canGoBack && + state.lastLoadedUrl != null && + canOpenInApp(state.lastLoadedUrl!!)) { AppBar.OverflowAction( title = UiText.StringResource(R.string.open_in_app), onClick = { state.lastLoadedUrl?.let(onOpenInApp) }, @@ -139,10 +137,8 @@ fun WebViewScreen( webView.setDefaultSettings() // Debug mode (chrome://inspect/#devices) - if ( - BuildConfig.DEBUG && - 0 != context.applicationInfo.flags and ApplicationInfo.FLAG_DEBUGGABLE - ) { + if (BuildConfig.DEBUG && + 0 != context.applicationInfo.flags and ApplicationInfo.FLAG_DEBUGGABLE) { WebView.setWebContentsDebuggingEnabled(true) } diff --git a/app/src/main/java/org/nekomanga/presentation/screens/browse/BrowseHomePage.kt b/app/src/main/java/org/nekomanga/presentation/screens/browse/BrowseHomePage.kt index 3b57ea7561..dd20514608 100644 --- a/app/src/main/java/org/nekomanga/presentation/screens/browse/BrowseHomePage.kt +++ b/app/src/main/java/org/nekomanga/presentation/screens/browse/BrowseHomePage.kt @@ -54,8 +54,7 @@ fun BrowseHomePage( val coverSize = (maxOf( LocalConfiguration.current.screenHeightDp, - LocalConfiguration.current.screenWidthDp - ) / 5) + LocalConfiguration.current.screenWidthDp) / 5) .dp LazyColumn( @@ -86,16 +85,14 @@ fun BrowseHomePage( text = headerText, style = MaterialTheme.typography.titleLarge.copy( - color = MaterialTheme.colorScheme.onSurface - ), + color = MaterialTheme.colorScheme.onSurface), ) Gap(Size.tiny) Icon( imageVector = Icons.Default.ArrowForward, modifier = Modifier.size(24.dp), contentDescription = null, - tint = MaterialTheme.colorScheme.onSurface - ) + tint = MaterialTheme.colorScheme.onSurface) } } Gap(Size.tiny) @@ -150,16 +147,14 @@ fun BrowseHomePage( text = stringResource(id = R.string.random_manga), style = MaterialTheme.typography.titleLarge.copy( - color = MaterialTheme.colorScheme.onSurface - ), + color = MaterialTheme.colorScheme.onSurface), ) Gap(Size.tiny) Icon( imageVector = Icons.Default.ArrowForward, modifier = Modifier.size(24.dp), contentDescription = null, - tint = MaterialTheme.colorScheme.onSurface - ) + tint = MaterialTheme.colorScheme.onSurface) } } } diff --git a/app/src/main/java/org/nekomanga/presentation/screens/mangadetails/ButtonBlock.kt b/app/src/main/java/org/nekomanga/presentation/screens/mangadetails/ButtonBlock.kt index adccf07c87..4cfc5404c1 100644 --- a/app/src/main/java/org/nekomanga/presentation/screens/mangadetails/ButtonBlock.kt +++ b/app/src/main/java/org/nekomanga/presentation/screens/mangadetails/ButtonBlock.kt @@ -85,8 +85,7 @@ fun ButtonBlock( Triple( PaddingValues(horizontal = 12.dp, vertical = Size.small), PaddingValues(horizontal = 12.dp, vertical = Size.tiny), - Modifier.height(Size.huge) - ) + Modifier.height(Size.huge)) } Row( @@ -103,15 +102,13 @@ fun ButtonBlock( icon = Icons.Filled.Favorite, buttonColors = checkedButtonColors, borderStroke = checkedBorderStroke, - text = stringResource(R.string.in_library) - ) + text = stringResource(R.string.in_library)) false -> ButtonConfig( icon = Icons.Filled.FavoriteBorder, buttonColors = uncheckedButtonColors, borderStroke = uncheckedBorderStroke, - text = stringResource(R.string.add_to_library) - ) + text = stringResource(R.string.add_to_library)) } OutlinedButton( @@ -126,8 +123,7 @@ fun ButtonBlock( imageVector = favConfig.icon!!, contentDescription = null, modifier = Modifier.size(24.dp), - tint = themeColorState.buttonColor - ) + tint = themeColorState.buttonColor) } if (loggedIntoTrackersProvider()) { @@ -147,8 +143,7 @@ fun ButtonBlock( icon = Icons.Filled.Sync, buttonColors = uncheckedButtonColors, borderStroke = uncheckedBorderStroke, - text = stringResource(R.string.tracking) - ) + text = stringResource(R.string.tracking)) } OutlinedButton( @@ -180,8 +175,7 @@ fun ButtonBlock( trackerConfig.icon!!, color = themeColorState.buttonColor, hideText = hideButtonTextProvider(), - text = trackerConfig.text - ) + text = trackerConfig.text) } } } @@ -217,8 +211,7 @@ fun ButtonBlock( Icons.Filled.AccountTree, color = themeColorState.buttonColor, hideText = hideButtonTextProvider(), - text = stringResource(R.string.similar_work) - ) + text = stringResource(R.string.similar_work)) } Gap(gapBetweenButtons) @@ -254,8 +247,7 @@ fun ButtonBlock( color = themeColorState.buttonColor, hideText = hideButtonTextProvider(), text = mergeConfig.text, - iconicsSize = 28.dp - ) + iconicsSize = 28.dp) } Gap(gapBetweenButtons) @@ -271,8 +263,7 @@ fun ButtonBlock( icon = Icons.Filled.OpenInBrowser, color = themeColorState.buttonColor, hideText = hideButtonTextProvider(), - text = stringResource(R.string.links) - ) + text = stringResource(R.string.links)) } Gap(gapBetweenButtons) @@ -288,8 +279,7 @@ fun ButtonBlock( icon = Icons.Filled.Share, color = themeColorState.buttonColor, hideText = hideButtonTextProvider(), - text = stringResource(R.string.share) - ) + text = stringResource(R.string.share)) } } } @@ -306,8 +296,7 @@ private fun RowScope.IconicsButtonContent( asset = iIcon, contentDescription = null, modifier = Modifier.size(iconicsSize), - colorFilter = ColorFilter.tint(color = color) - ) + colorFilter = ColorFilter.tint(color = color)) if (!hideText) { ButtonText(text = text, color = color) } @@ -324,8 +313,7 @@ private fun RowScope.ButtonContent( imageVector = icon, contentDescription = null, modifier = Modifier.size(24.dp), - tint = color - ) + tint = color) if (!hideText) { ButtonText(text = text, color = color) } @@ -341,9 +329,7 @@ private fun RowScope.ButtonText(text: String, color: Color) { MaterialTheme.typography.bodyLarge.copy( color = color.copy(alpha = .8f), letterSpacing = (-.5).sp, - fontWeight = FontWeight.Medium - ) - ) + fontWeight = FontWeight.Medium)) } } diff --git a/app/src/main/java/org/nekomanga/presentation/screens/mangadetails/ChapterHeader.kt b/app/src/main/java/org/nekomanga/presentation/screens/mangadetails/ChapterHeader.kt index 0d654b3146..a600755f60 100644 --- a/app/src/main/java/org/nekomanga/presentation/screens/mangadetails/ChapterHeader.kt +++ b/app/src/main/java/org/nekomanga/presentation/screens/mangadetails/ChapterHeader.kt @@ -55,9 +55,7 @@ fun ChapterHeader( MaterialTheme.typography.bodyMedium.copy( color = MaterialTheme.colorScheme.onSurface.copy( - alpha = NekoColors.disabledAlphaHighContrast - ) - ), + alpha = NekoColors.disabledAlphaHighContrast)), modifier = Modifier.requiredWidthIn(Size.none, 200.dp) .align(Alignment.CenterVertically) @@ -81,10 +79,7 @@ private fun ChapterText(numberOfChapters: Int, modifier: Modifier = Modifier) { Text( text = resources.getQuantityString( - R.plurals.chapters_plural, - numberOfChapters, - numberOfChapters - ), + R.plurals.chapters_plural, numberOfChapters, numberOfChapters), style = MaterialTheme.typography.titleLarge, color = MaterialTheme.colorScheme.onSurface.copy(alpha = NekoColors.highAlphaLowContrast), modifier = modifier, diff --git a/app/src/main/java/org/nekomanga/presentation/screens/mangadetails/DescriptionBlock.kt b/app/src/main/java/org/nekomanga/presentation/screens/mangadetails/DescriptionBlock.kt index 7c42513078..f3d82d7126 100644 --- a/app/src/main/java/org/nekomanga/presentation/screens/mangadetails/DescriptionBlock.kt +++ b/app/src/main/java/org/nekomanga/presentation/screens/mangadetails/DescriptionBlock.kt @@ -87,9 +87,7 @@ fun DescriptionBlock( val tagColor = MaterialTheme.colorScheme.surfaceColorAtElevationCustomColor( - themeColorState.buttonColor, - 16.dp - ) + themeColorState.buttonColor, 16.dp) val interactionSource = remember { MutableInteractionSource() } @@ -144,16 +142,12 @@ fun DescriptionBlock( listOf( Color.Transparent, MaterialTheme.colorScheme.surface.copy(alpha = .8f), - MaterialTheme.colorScheme.surface - ), + MaterialTheme.colorScheme.surface), ), ), ) { MoreLessButton( - themeColorState.buttonColor, - true, - Modifier.align(Alignment.TopEnd) - ) + themeColorState.buttonColor, true, Modifier.align(Alignment.TopEnd)) } } } else { @@ -234,8 +228,7 @@ private fun MoreLessButton(buttonColor: Color, isMore: Boolean, modifier: Modifi modifier = Modifier.align(Alignment.CenterVertically), imageVector = icon, contentDescription = null, - tint = buttonColor - ) + tint = buttonColor) } } @@ -253,8 +246,7 @@ private fun AltTitles( val isCustomTitle = altTitles.contains(currentTitle) val onChipColor = MaterialTheme.colorScheme.onSurfaceVariant.copy( - alpha = NekoColors.mediumAlphaHighContrast - ) + alpha = NekoColors.mediumAlphaHighContrast) Text( text = "Alt Titles:", @@ -301,50 +293,45 @@ private fun FlowableAltTitles( ) { FlowRow( modifier = Modifier.fillMaxWidth(), - horizontalArrangement = Arrangement.spacedBy(Size.small) - ) { - if (isCustomTitle) { - TextButton(onClick = resetClick) { - Text( - text = stringResource(id = R.string.reset), - style = MaterialTheme.typography.labelMedium, - color = themeColorState.buttonColor - ) + horizontalArrangement = Arrangement.spacedBy(Size.small)) { + if (isCustomTitle) { + TextButton(onClick = resetClick) { + Text( + text = stringResource(id = R.string.reset), + style = MaterialTheme.typography.labelMedium, + color = themeColorState.buttonColor) + } } - } - altTitles.forEach { title -> - val currentlySelected = isCustomTitle && title == currentTitle - AssistChip( - onClick = { - if (!currentlySelected) { - altTitleClick(title) - } - }, - colors = - AssistChipDefaults.assistChipColors( - containerColor = tagColor, - labelColor = onChipColor - ), - border = null, - leadingIcon = { - if (currentlySelected) { - Icon( - imageVector = Icons.Filled.Check, - contentDescription = null, - tint = onChipColor + altTitles.forEach { title -> + val currentlySelected = isCustomTitle && title == currentTitle + AssistChip( + onClick = { + if (!currentlySelected) { + altTitleClick(title) + } + }, + colors = + AssistChipDefaults.assistChipColors( + containerColor = tagColor, labelColor = onChipColor), + border = null, + leadingIcon = { + if (currentlySelected) { + Icon( + imageVector = Icons.Filled.Check, + contentDescription = null, + tint = onChipColor) + } + }, + label = { + Text( + text = title, + style = MaterialTheme.typography.labelSmall, + modifier = Modifier.padding(Size.none), ) - } - }, - label = { - Text( - text = title, - style = MaterialTheme.typography.labelSmall, - modifier = Modifier.padding(Size.none), - ) - }, - ) + }, + ) + } } - } } @Composable @@ -379,8 +366,7 @@ private fun ScrollableAltTitles( Text( text = stringResource(id = R.string.reset), style = MaterialTheme.typography.labelMedium, - color = themeColorState.buttonColor - ) + color = themeColorState.buttonColor) } } } @@ -396,17 +382,14 @@ private fun ScrollableAltTitles( }, colors = AssistChipDefaults.assistChipColors( - containerColor = tagColor, - labelColor = onChipColor - ), + containerColor = tagColor, labelColor = onChipColor), border = null, leadingIcon = { if (currentlySelected) { Icon( imageVector = Icons.Filled.Check, contentDescription = null, - tint = onChipColor - ) + tint = onChipColor) } }, label = { @@ -478,11 +461,10 @@ private fun ColumnScope.Genres( genreSearch(genres[genrePosition]) }, SimpleDropDownItem.Action( - text = UiText.StringResource(R.string.search_library) - ) { - genreExpanded = false - genreLibrarySearch(genres[genrePosition]) - }, + text = UiText.StringResource(R.string.search_library)) { + genreExpanded = false + genreLibrarySearch(genres[genrePosition]) + }, ) .toPersistentList(), ) diff --git a/app/src/main/java/org/nekomanga/presentation/screens/mangadetails/DetailsBottomSheet.kt b/app/src/main/java/org/nekomanga/presentation/screens/mangadetails/DetailsBottomSheet.kt index 88b32fd33b..a419b24a78 100644 --- a/app/src/main/java/org/nekomanga/presentation/screens/mangadetails/DetailsBottomSheet.kt +++ b/app/src/main/java/org/nekomanga/presentation/screens/mangadetails/DetailsBottomSheet.kt @@ -104,8 +104,7 @@ fun DetailsBottomSheet( DetailsBottomSheetScreen.TrackingDateSheet( trackAndService, trackingDate, - generalState.value.trackingSuggestedDates - ), + generalState.value.trackingSuggestedDates), ) }, trackingFinishDateClick = { trackAndService, trackingDate -> @@ -114,8 +113,7 @@ fun DetailsBottomSheet( DetailsBottomSheetScreen.TrackingDateSheet( trackAndService, trackingDate, - generalState.value.trackingSuggestedDates - ), + generalState.value.trackingSuggestedDates), ) }, ) @@ -145,10 +143,7 @@ fun DetailsBottomSheet( closeSheet() trackActions.searchItemClick( TrackingConstants.TrackAndService( - trackSearch.trackItem, - currentScreen.trackingService - ) - ) + trackSearch.trackItem, currentScreen.trackingService)) openSheet(DetailsBottomSheetScreen.TrackingSheet) }, ) diff --git a/app/src/main/java/org/nekomanga/presentation/screens/mangadetails/InformationBlock.kt b/app/src/main/java/org/nekomanga/presentation/screens/mangadetails/InformationBlock.kt index ee970554d7..9dd54211d7 100644 --- a/app/src/main/java/org/nekomanga/presentation/screens/mangadetails/InformationBlock.kt +++ b/app/src/main/java/org/nekomanga/presentation/screens/mangadetails/InformationBlock.kt @@ -84,9 +84,7 @@ fun InformationBlock( onLongClick = titleLongClick, style = MaterialTheme.typography.headlineSmall.copy( - letterSpacing = (-.5).sp, - fontWeight = FontWeight.Medium - ), + letterSpacing = (-.5).sp, fontWeight = FontWeight.Medium), color = highAlpha, ) } @@ -124,17 +122,15 @@ fun InformationBlock( children = listOf( SimpleDropDownItem.Action( - text = UiText.StringResource(R.string.copy) - ) { - creatorExpanded = false - creatorCopyClick(individualCreator) - }, + text = UiText.StringResource(R.string.copy)) { + creatorExpanded = false + creatorCopyClick(individualCreator) + }, SimpleDropDownItem.Action( - text = UiText.StringResource(R.string.search) - ) { - creatorExpanded = false - creatorSearchClick(individualCreator) - }, + text = UiText.StringResource(R.string.search)) { + creatorExpanded = false + creatorSearchClick(individualCreator) + }, ), ) } @@ -176,8 +172,7 @@ fun InformationBlock( painter = rememberDrawablePainter( drawable = - AppCompatResources.getDrawable(LocalContext.current, flag) - ), + AppCompatResources.getDrawable(LocalContext.current, flag)), modifier = Modifier.height(Size.large).clip(RoundedCornerShape(Size.tiny)), contentDescription = "flag", ) @@ -202,8 +197,7 @@ fun InformationBlock( Image( imageVector = Icons.Filled.HotelClass, contentDescription = null, - colorFilter = ColorFilter.tint(mediumAlpha) - ) + colorFilter = ColorFilter.tint(mediumAlpha)) Gap(Size.tiny) NoRippleText( text = formattedRating, @@ -225,8 +219,7 @@ fun InformationBlock( Image( imageVector = Icons.Filled.Bookmarks, contentDescription = null, - colorFilter = ColorFilter.tint(mediumAlpha) - ) + colorFilter = ColorFilter.tint(mediumAlpha)) Gap(Size.tiny) NoRippleText( text = numberOfUsers, @@ -249,8 +242,7 @@ fun InformationBlock( Image( imageVector = Icons.Filled.Comment, contentDescription = null, - colorFilter = ColorFilter.tint(mediumAlpha) - ) + colorFilter = ColorFilter.tint(mediumAlpha)) Gap(Size.tiny) NoRippleText( text = numberOfComments, @@ -264,8 +256,7 @@ fun InformationBlock( Gap(Size.tiny) com.mikepenz.iconics.compose.Image( asset = CommunityMaterial.Icon.cmd_check_decagram, - colorFilter = ColorFilter.tint(mediumAlpha) - ) + colorFilter = ColorFilter.tint(mediumAlpha)) } } diff --git a/app/src/main/java/org/nekomanga/presentation/screens/mangadetails/MangaDetailsHeader.kt b/app/src/main/java/org/nekomanga/presentation/screens/mangadetails/MangaDetailsHeader.kt index 0d793936a3..2bb462664f 100644 --- a/app/src/main/java/org/nekomanga/presentation/screens/mangadetails/MangaDetailsHeader.kt +++ b/app/src/main/java/org/nekomanga/presentation/screens/mangadetails/MangaDetailsHeader.kt @@ -78,167 +78,164 @@ fun MangaDetailsHeader( ) { CompositionLocalProvider( LocalRippleTheme provides themeColorState.rippleTheme, - LocalTextSelectionColors provides themeColorState.textSelectionColors - ) { - var favoriteExpanded by rememberSaveable { mutableStateOf(false) } + LocalTextSelectionColors provides themeColorState.textSelectionColors) { + var favoriteExpanded by rememberSaveable { mutableStateOf(false) } - val isExpanded = - rememberSaveable(mangaState.value.inLibrary) { - when (windowSizeClass.widthSizeClass == WindowWidthSizeClass.Expanded) { - true -> mutableStateOf(true) - false -> mutableStateOf(!mangaState.value.inLibrary) - } - } - val backdropHeight = - when (isSearching) { - true -> (LocalConfiguration.current.screenHeightDp / 4).dp - false -> { - when (generalState.value.extraLargeBackdrop) { - true -> (LocalConfiguration.current.screenHeightDp / 1.2).dp - false -> (LocalConfiguration.current.screenHeightDp / 2.1).dp + val isExpanded = + rememberSaveable(mangaState.value.inLibrary) { + when (windowSizeClass.widthSizeClass == WindowWidthSizeClass.Expanded) { + true -> mutableStateOf(true) + false -> mutableStateOf(!mangaState.value.inLibrary) } } - } - - Column { - BoxWithConstraints { - BackDrop( - themeColorState = themeColorState, - artworkProvider = { mangaState.value.currentArtwork }, - showBackdropProvider = { generalState.value.themeBasedOffCovers }, - modifier = - Modifier.animateContentSize() - .fillMaxWidth() - .requiredHeightIn(250.dp, maxOf(250.dp, backdropHeight)), - generatePalette = generatePalette, - ) - Box( - modifier = - Modifier.align(Alignment.BottomStart) - .fillMaxWidth() - .height(200.dp) - .background( - Brush.verticalGradient( - colors = - listOf( - Color.Transparent, - MaterialTheme.colorScheme.surface - ), - ), - ), - ) - - Column(modifier = Modifier.align(Alignment.BottomStart)) { - InformationBlock( - themeColorState = themeColorState, - titleProvider = { mangaState.value.currentTitle }, - authorProvider = { mangaState.value.author }, - artistProvider = { mangaState.value.artist }, - statsProvider = { mangaState.value.stats }, - langFlagProvider = { mangaState.value.langFlag }, - statusProvider = { mangaState.value.status }, - isPornographicProvider = { mangaState.value.isPornographic }, - missingChaptersProvider = { mangaState.value.missingChapters }, - estimatedMissingChapterProvider = { - mangaState.value.estimatedMissingChapters - }, - modifier = Modifier.statusBarsPadding().padding(top = 70.dp), - isExpandedProvider = { isExpanded.value }, - showMergedIconProvider = { - mangaState.value.isMerged is MergeConstants.IsMergedManga.Yes && - !generalState.value.hideButtonText - }, - titleLongClick = informationActions.titleLongClick, - creatorCopyClick = informationActions.creatorCopy, - creatorSearchClick = informationActions.creatorSearch, - ) - AnimatedVisibility( - visible = !isSearching, - enter = fadeIn() + expandVertically(), - exit = fadeOut() + shrinkVertically() - ) { - Column { - Gap(height = 16.dp) - ButtonBlock( - hideButtonTextProvider = { generalState.value.hideButtonText }, - isInitializedProvider = { mangaState.value.initialized }, - isMergedProvider = { - mangaState.value.isMerged is MergeConstants.IsMergedManga.Yes - }, - inLibraryProvider = { mangaState.value.inLibrary }, - loggedIntoTrackersProvider = isLoggedIntoTrackersProvider, - trackServiceCountProvider = { - generalState.value.trackServiceCount - }, - themeColorState = themeColorState, - favoriteClick = { - if (!mangaState.value.inLibrary) { - toggleFavorite() - } else { - favoriteExpanded = true - } - }, - trackingClick = trackingClick, - artworkClick = artworkClick, - similarClick = similarClick, - mergeClick = mergeClick, - linksClick = linksClick, - shareClick = shareClick, - ) - FavoriteDropDown( - favoriteExpanded = favoriteExpanded, - themeColorState = themeColorState, - moveCategories = moveCategories, - toggleFavorite = toggleFavorite, - onDismiss = { favoriteExpanded = false }, - ) - Gap(height = 16.dp) + val backdropHeight = + when (isSearching) { + true -> (LocalConfiguration.current.screenHeightDp / 4).dp + false -> { + when (generalState.value.extraLargeBackdrop) { + true -> (LocalConfiguration.current.screenHeightDp / 1.2).dp + false -> (LocalConfiguration.current.screenHeightDp / 2.1).dp } } } - } - } - AnimatedVisibility( - visible = !isSearching, - enter = fadeIn() + expandVertically(), - exit = fadeOut() + shrinkVertically() - ) { + Column { - if (windowSizeClass.widthSizeClass == WindowWidthSizeClass.Expanded) { - QuickReadButton( - { generalState.value.nextUnreadChapter }, - themeColorState, - quickReadClick + BoxWithConstraints { + BackDrop( + themeColorState = themeColorState, + artworkProvider = { mangaState.value.currentArtwork }, + showBackdropProvider = { generalState.value.themeBasedOffCovers }, + modifier = + Modifier.animateContentSize() + .fillMaxWidth() + .requiredHeightIn(250.dp, maxOf(250.dp, backdropHeight)), + generatePalette = generatePalette, ) - } - Gap(Size.tiny) - DescriptionBlock( - windowSizeClass = windowSizeClass, - titleProvider = { mangaState.value.currentTitle }, - descriptionProvider = { mangaState.value.currentDescription }, - isInitializedProvider = { mangaState.value.initialized }, - altTitlesProvider = { mangaState.value.alternativeTitles }, - genresProvider = { mangaState.value.genres }, - themeColorState = themeColorState, - isExpanded = isExpanded.value, - wrapAltTitles = generalState.value.wrapAltTitles, - expandCollapseClick = { isExpanded.value = !isExpanded.value }, - genreSearch = descriptionActions.genreSearch, - genreSearchLibrary = descriptionActions.genreSearchLibrary, - altTitleClick = descriptionActions.altTitleClick, - altTitleResetClick = descriptionActions.altTitleResetClick, - ) - if (windowSizeClass.widthSizeClass != WindowWidthSizeClass.Expanded) { - QuickReadButton( - { generalState.value.nextUnreadChapter }, - themeColorState, - quickReadClick + Box( + modifier = + Modifier.align(Alignment.BottomStart) + .fillMaxWidth() + .height(200.dp) + .background( + Brush.verticalGradient( + colors = + listOf( + Color.Transparent, + MaterialTheme.colorScheme.surface), + ), + ), ) - Gap(Size.tiny) + + Column(modifier = Modifier.align(Alignment.BottomStart)) { + InformationBlock( + themeColorState = themeColorState, + titleProvider = { mangaState.value.currentTitle }, + authorProvider = { mangaState.value.author }, + artistProvider = { mangaState.value.artist }, + statsProvider = { mangaState.value.stats }, + langFlagProvider = { mangaState.value.langFlag }, + statusProvider = { mangaState.value.status }, + isPornographicProvider = { mangaState.value.isPornographic }, + missingChaptersProvider = { mangaState.value.missingChapters }, + estimatedMissingChapterProvider = { + mangaState.value.estimatedMissingChapters + }, + modifier = Modifier.statusBarsPadding().padding(top = 70.dp), + isExpandedProvider = { isExpanded.value }, + showMergedIconProvider = { + mangaState.value.isMerged is MergeConstants.IsMergedManga.Yes && + !generalState.value.hideButtonText + }, + titleLongClick = informationActions.titleLongClick, + creatorCopyClick = informationActions.creatorCopy, + creatorSearchClick = informationActions.creatorSearch, + ) + AnimatedVisibility( + visible = !isSearching, + enter = fadeIn() + expandVertically(), + exit = fadeOut() + shrinkVertically()) { + Column { + Gap(height = 16.dp) + ButtonBlock( + hideButtonTextProvider = { + generalState.value.hideButtonText + }, + isInitializedProvider = { mangaState.value.initialized }, + isMergedProvider = { + mangaState.value.isMerged is + MergeConstants.IsMergedManga.Yes + }, + inLibraryProvider = { mangaState.value.inLibrary }, + loggedIntoTrackersProvider = isLoggedIntoTrackersProvider, + trackServiceCountProvider = { + generalState.value.trackServiceCount + }, + themeColorState = themeColorState, + favoriteClick = { + if (!mangaState.value.inLibrary) { + toggleFavorite() + } else { + favoriteExpanded = true + } + }, + trackingClick = trackingClick, + artworkClick = artworkClick, + similarClick = similarClick, + mergeClick = mergeClick, + linksClick = linksClick, + shareClick = shareClick, + ) + FavoriteDropDown( + favoriteExpanded = favoriteExpanded, + themeColorState = themeColorState, + moveCategories = moveCategories, + toggleFavorite = toggleFavorite, + onDismiss = { favoriteExpanded = false }, + ) + Gap(height = 16.dp) + } + } + } } } + AnimatedVisibility( + visible = !isSearching, + enter = fadeIn() + expandVertically(), + exit = fadeOut() + shrinkVertically()) { + Column { + if (windowSizeClass.widthSizeClass == WindowWidthSizeClass.Expanded) { + QuickReadButton( + { generalState.value.nextUnreadChapter }, + themeColorState, + quickReadClick) + } + Gap(Size.tiny) + DescriptionBlock( + windowSizeClass = windowSizeClass, + titleProvider = { mangaState.value.currentTitle }, + descriptionProvider = { mangaState.value.currentDescription }, + isInitializedProvider = { mangaState.value.initialized }, + altTitlesProvider = { mangaState.value.alternativeTitles }, + genresProvider = { mangaState.value.genres }, + themeColorState = themeColorState, + isExpanded = isExpanded.value, + wrapAltTitles = generalState.value.wrapAltTitles, + expandCollapseClick = { isExpanded.value = !isExpanded.value }, + genreSearch = descriptionActions.genreSearch, + genreSearchLibrary = descriptionActions.genreSearchLibrary, + altTitleClick = descriptionActions.altTitleClick, + altTitleResetClick = descriptionActions.altTitleResetClick, + ) + if (windowSizeClass.widthSizeClass != WindowWidthSizeClass.Expanded) { + QuickReadButton( + { generalState.value.nextUnreadChapter }, + themeColorState, + quickReadClick) + Gap(Size.tiny) + } + } + } } - } } @Composable @@ -250,28 +247,23 @@ private fun ColumnScope.QuickReadButton( if (quickReadTextProvider().text.isNotEmpty() && quickReadTextProvider().id != null) { Gap(Size.tiny) CompositionLocalProvider( - LocalRippleTheme provides DynamicRippleTheme(themeColorState.altContainerColor) - ) { - ElevatedButton( - onClick = quickReadClick, - shape = RoundedCornerShape(35), - modifier = Modifier.fillMaxWidth().padding(Size.small), - colors = - ButtonDefaults.elevatedButtonColors( - containerColor = themeColorState.buttonColor - ), - ) { - Text( - text = - stringResource( - id = quickReadTextProvider().id!!, - quickReadTextProvider().text - ), - style = MaterialTheme.typography.titleMedium, - color = MaterialTheme.colorScheme.surface - ) + LocalRippleTheme provides DynamicRippleTheme(themeColorState.altContainerColor)) { + ElevatedButton( + onClick = quickReadClick, + shape = RoundedCornerShape(35), + modifier = Modifier.fillMaxWidth().padding(Size.small), + colors = + ButtonDefaults.elevatedButtonColors( + containerColor = themeColorState.buttonColor), + ) { + Text( + text = + stringResource( + id = quickReadTextProvider().id!!, quickReadTextProvider().text), + style = MaterialTheme.typography.titleMedium, + color = MaterialTheme.colorScheme.surface) + } } - } } } diff --git a/app/src/main/java/org/nekomanga/presentation/screens/mangadetails/OverflowOptions.kt b/app/src/main/java/org/nekomanga/presentation/screens/mangadetails/OverflowOptions.kt index 3845fa2af0..9bbc19c580 100644 --- a/app/src/main/java/org/nekomanga/presentation/screens/mangadetails/OverflowOptions.kt +++ b/app/src/main/java/org/nekomanga/presentation/screens/mangadetails/OverflowOptions.kt @@ -31,8 +31,7 @@ fun OverflowOptions( chapterActions.download( emptyList(), MangaConstants.DownloadAction - .DownloadNextUnread(1) - ) + .DownloadNextUnread(1)) }, ), AppBar.OverflowAction( @@ -41,8 +40,7 @@ fun OverflowOptions( chapterActions.download( emptyList(), MangaConstants.DownloadAction - .DownloadNextUnread(5) - ) + .DownloadNextUnread(5)) }, ), AppBar.OverflowAction( @@ -51,8 +49,7 @@ fun OverflowOptions( chapterActions.download( emptyList(), MangaConstants.DownloadAction - .DownloadNextUnread(10) - ) + .DownloadNextUnread(10)) }, ), ), @@ -61,18 +58,14 @@ fun OverflowOptions( title = UiText.StringResource(R.string.unread), onClick = { chapterActions.download( - emptyList(), - MangaConstants.DownloadAction.DownloadUnread - ) + emptyList(), MangaConstants.DownloadAction.DownloadUnread) }, ), AppBar.OverflowAction( title = UiText.StringResource(R.string.all), onClick = { chapterActions.download( - emptyList(), - MangaConstants.DownloadAction.DownloadAll - ) + emptyList(), MangaConstants.DownloadAction.DownloadAll) }, ), ), @@ -85,18 +78,14 @@ fun OverflowOptions( title = UiText.StringResource(R.string.read), onClick = { chapterActions.mark( - chaptersProvider(), - MangaConstants.MarkAction.Read(true) - ) + chaptersProvider(), MangaConstants.MarkAction.Read(true)) }, ), AppBar.OverflowAction( title = UiText.StringResource(R.string.unread), onClick = { chapterActions.mark( - chaptersProvider(), - MangaConstants.MarkAction.Unread(true) - ) + chaptersProvider(), MangaConstants.MarkAction.Unread(true)) }, ), ), @@ -109,18 +98,14 @@ fun OverflowOptions( title = UiText.StringResource(R.string.all), onClick = { chapterActions.download( - emptyList(), - MangaConstants.DownloadAction.RemoveAll - ) + emptyList(), MangaConstants.DownloadAction.RemoveAll) }, ), AppBar.OverflowAction( title = UiText.StringResource(R.string.read), onClick = { chapterActions.download( - emptyList(), - MangaConstants.DownloadAction.RemoveRead - ) + emptyList(), MangaConstants.DownloadAction.RemoveRead) }, ), ), diff --git a/app/src/main/java/org/nekomanga/presentation/screens/onboarding/FirstStep.kt b/app/src/main/java/org/nekomanga/presentation/screens/onboarding/FirstStep.kt index 3d977e8dcb..e3f68eea6e 100644 --- a/app/src/main/java/org/nekomanga/presentation/screens/onboarding/FirstStep.kt +++ b/app/src/main/java/org/nekomanga/presentation/screens/onboarding/FirstStep.kt @@ -29,32 +29,27 @@ class FirstStep : OnboardingStep { text = stringResource( R.string.onboarding_guides_returning_user, - stringResource(R.string.app_name) - ), + stringResource(R.string.app_name)), style = MaterialTheme.typography.titleLarge, - textAlign = TextAlign.Center - ) + textAlign = TextAlign.Center) Gap(Size.medium) Text( modifier = Modifier.fillMaxWidth(), text = stringResource(R.string.onboarding_guides_new_version), - textAlign = TextAlign.Center - ) + textAlign = TextAlign.Center) Gap(Size.medium) Text( modifier = Modifier.fillMaxWidth(), text = stringResource(R.string.onboarding_guides_restore_backup), - textAlign = TextAlign.Center - ) + textAlign = TextAlign.Center) Text( modifier = Modifier.fillMaxWidth(), color = MaterialTheme.colorScheme.primary, fontWeight = FontWeight.Bold, text = stringResource(R.string.onboarding_guides_restore_backup_setting_location), - textAlign = TextAlign.Center - ) + textAlign = TextAlign.Center) } } } diff --git a/app/src/main/java/org/nekomanga/presentation/screens/onboarding/PermissionStep.kt b/app/src/main/java/org/nekomanga/presentation/screens/onboarding/PermissionStep.kt index e2dd7dc321..5738b5142f 100644 --- a/app/src/main/java/org/nekomanga/presentation/screens/onboarding/PermissionStep.kt +++ b/app/src/main/java/org/nekomanga/presentation/screens/onboarding/PermissionStep.kt @@ -58,16 +58,14 @@ internal class PermissionStep : OnboardingStep { PackageManager.PERMISSION_GRANTED } else { true - } - ) + }) } var batteryGranted by remember { mutableStateOf( context .getSystemService()!! - .isIgnoringBatteryOptimizations(context.packageName) - ) + .isIgnoringBatteryOptimizations(context.packageName)) } DisposableEffect(lifecycleOwner.lifecycle) { @@ -79,9 +77,8 @@ internal class PermissionStep : OnboardingStep { } else { @Suppress("DEPRECATION") Settings.Secure.getInt( - context.contentResolver, - Settings.Secure.INSTALL_NON_MARKET_APPS - ) != 0 + context.contentResolver, Settings.Secure.INSTALL_NON_MARKET_APPS) != + 0 } batteryGranted = context diff --git a/app/src/main/java/org/nekomanga/presentation/screens/onboarding/StorageStep.kt b/app/src/main/java/org/nekomanga/presentation/screens/onboarding/StorageStep.kt index 5080b3384c..e49a47332f 100644 --- a/app/src/main/java/org/nekomanga/presentation/screens/onboarding/StorageStep.kt +++ b/app/src/main/java/org/nekomanga/presentation/screens/onboarding/StorageStep.kt @@ -85,16 +85,12 @@ internal class StorageStep : OnboardingStep { Text( stringResource( - R.string.onboarding_storage_help_info, - stringResource(R.string.app_name) - ) - ) + R.string.onboarding_storage_help_info, stringResource(R.string.app_name))) Button( modifier = Modifier.fillMaxWidth(), onClick = { handler.openUri( - "https://mihon.app/docs/faq/storage#migrating-from-tachiyomi-v0-14-x-or-earlier" - ) + "https://mihon.app/docs/faq/storage#migrating-from-tachiyomi-v0-14-x-or-earlier") }, ) { Text(stringResource(R.string.onboarding_storage_help_action)) diff --git a/app/src/main/java/org/nekomanga/presentation/screens/onboarding/ThemeStep.kt b/app/src/main/java/org/nekomanga/presentation/screens/onboarding/ThemeStep.kt index 346565675d..4635e8bb0d 100644 --- a/app/src/main/java/org/nekomanga/presentation/screens/onboarding/ThemeStep.kt +++ b/app/src/main/java/org/nekomanga/presentation/screens/onboarding/ThemeStep.kt @@ -91,81 +91,72 @@ internal class ThemeStep : OnboardingStep { Row( modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween, - verticalAlignment = Alignment.CenterVertically - ) { - Text(text = stringResource(id = R.string.follow_system_theme)) - Switch( - checked = nightMode == AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM, - colors = - SwitchDefaults.colors( - checkedTrackColor = MaterialTheme.colorScheme.primary - ), - onCheckedChange = { - when (it) { - true -> { - preferences - .nightMode() - .set(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM) - (context as? Activity)?.let { activity -> - ActivityCompat.recreate(activity) + verticalAlignment = Alignment.CenterVertically) { + Text(text = stringResource(id = R.string.follow_system_theme)) + Switch( + checked = nightMode == AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM, + colors = + SwitchDefaults.colors( + checkedTrackColor = MaterialTheme.colorScheme.primary), + onCheckedChange = { + when (it) { + true -> { + preferences + .nightMode() + .set(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM) + (context as? Activity)?.let { activity -> + ActivityCompat.recreate(activity) + } } + false -> preferences.nightMode().set(context.appDelegateNightMode()) } - false -> preferences.nightMode().set(context.appDelegateNightMode()) - } - } - ) - } + }) + } Row( modifier = Modifier.horizontalScroll(rememberScrollState()), - horizontalArrangement = Arrangement.spacedBy(Size.medium) - ) { - lightThemes.forEach { theme -> - val isSelected = - remember(darkAppTheme, lightAppTheme, nightMode) { - isSelected(theme, false, darkAppTheme, lightAppTheme, nightMode) - } - ThemeItem( - theme = theme, - isDarkTheme = false, - selected = isSelected, - onClick = { - themeClicked( - theme, - context, - isSelected = isSelected, - followingSystemTheme = followingSystemTheme, - isDarkTheme = false - ) - } - ) + horizontalArrangement = Arrangement.spacedBy(Size.medium)) { + lightThemes.forEach { theme -> + val isSelected = + remember(darkAppTheme, lightAppTheme, nightMode) { + isSelected(theme, false, darkAppTheme, lightAppTheme, nightMode) + } + ThemeItem( + theme = theme, + isDarkTheme = false, + selected = isSelected, + onClick = { + themeClicked( + theme, + context, + isSelected = isSelected, + followingSystemTheme = followingSystemTheme, + isDarkTheme = false) + }) + } } - } Row( modifier = Modifier.horizontalScroll(rememberScrollState()), - horizontalArrangement = Arrangement.spacedBy(Size.medium) - ) { - darkThemes.forEach { theme -> - val isSelected = - remember(darkAppTheme, lightAppTheme, nightMode) { - isSelected(theme, true, darkAppTheme, lightAppTheme, nightMode) - } - ThemeItem( - theme = theme, - isDarkTheme = true, - selected = isSelected, - onClick = { - themeClicked( - theme, - context, - isSelected = isSelected, - followingSystemTheme = followingSystemTheme, - isDarkTheme = true - ) - } - ) + horizontalArrangement = Arrangement.spacedBy(Size.medium)) { + darkThemes.forEach { theme -> + val isSelected = + remember(darkAppTheme, lightAppTheme, nightMode) { + isSelected(theme, true, darkAppTheme, lightAppTheme, nightMode) + } + ThemeItem( + theme = theme, + isDarkTheme = true, + selected = isSelected, + onClick = { + themeClicked( + theme, + context, + isSelected = isSelected, + followingSystemTheme = followingSystemTheme, + isDarkTheme = true) + }) + } } - } } } diff --git a/app/src/main/java/org/nekomanga/presentation/screens/stats/DetailedStats.kt b/app/src/main/java/org/nekomanga/presentation/screens/stats/DetailedStats.kt index 9697cf4b70..02b4c1450a 100644 --- a/app/src/main/java/org/nekomanga/presentation/screens/stats/DetailedStats.kt +++ b/app/src/main/java/org/nekomanga/presentation/screens/stats/DetailedStats.kt @@ -127,8 +127,7 @@ fun DetailedStats( colors, contentPadding, viewType, - sortChipClick - ) + sortChipClick) } Filter.Status -> { StatusView( @@ -138,28 +137,15 @@ fun DetailedStats( colors, contentPadding, viewType, - sortChipClick - ) + sortChipClick) } Filter.ContentRating -> { ContentRatingView( - sortType, - detailedStats, - colors, - contentPadding, - viewType, - sortChipClick - ) + sortType, detailedStats, colors, contentPadding, viewType, sortChipClick) } Filter.Category -> { CategoryView( - sortType, - detailedStats, - colors, - contentPadding, - viewType, - sortChipClick - ) + sortType, detailedStats, colors, contentPadding, viewType, sortChipClick) } Filter.Tag -> { TagView(sortType, detailedStats, colors, contentPadding, viewType, sortChipClick) @@ -175,40 +161,39 @@ fun DetailedStats( private fun FilterChipHeader(filterState: Filter, filterStateClick: (Filter) -> Unit) { LazyRow( modifier = Modifier.fillMaxWidth(), - horizontalArrangement = Arrangement.spacedBy(Size.tiny) - ) { - item { Gap(Size.tiny) } - CustomChip( - isSelected = filterState == Filter.Type, - onClick = { filterStateClick(Filter.Type) }, - label = R.string.series_type, - ) - CustomChip( - isSelected = filterState == Filter.Status, - onClick = { filterStateClick(Filter.Status) }, - label = R.string.status, - ) - CustomChip( - isSelected = filterState == Filter.ContentRating, - onClick = { filterStateClick(Filter.ContentRating) }, - label = R.string.content_rating_distribution, - ) - CustomChip( - isSelected = filterState == Filter.Category, - onClick = { filterStateClick(Filter.Category) }, - label = R.string.categories, - ) - CustomChip( - isSelected = filterState == Filter.Tag, - onClick = { filterStateClick(Filter.Tag) }, - label = R.string.tag, - ) - /* CustomChip( - isSelected = filterState == Filter.StartYear, - onClick = { filterStateClick(Filter.StartYear) }, - label = R.string.start_year, - )*/ - } + horizontalArrangement = Arrangement.spacedBy(Size.tiny)) { + item { Gap(Size.tiny) } + CustomChip( + isSelected = filterState == Filter.Type, + onClick = { filterStateClick(Filter.Type) }, + label = R.string.series_type, + ) + CustomChip( + isSelected = filterState == Filter.Status, + onClick = { filterStateClick(Filter.Status) }, + label = R.string.status, + ) + CustomChip( + isSelected = filterState == Filter.ContentRating, + onClick = { filterStateClick(Filter.ContentRating) }, + label = R.string.content_rating_distribution, + ) + CustomChip( + isSelected = filterState == Filter.Category, + onClick = { filterStateClick(Filter.Category) }, + label = R.string.categories, + ) + CustomChip( + isSelected = filterState == Filter.Tag, + onClick = { filterStateClick(Filter.Tag) }, + label = R.string.tag, + ) + /* CustomChip( + isSelected = filterState == Filter.StartYear, + onClick = { filterStateClick(Filter.StartYear) }, + label = R.string.start_year, + )*/ + } } @Composable @@ -379,8 +364,7 @@ private fun StartYearView( lineData = lineData, chartWidth = chartWidth, modifier = modifier, - color = MaterialTheme.colorScheme.secondary - ) + color = MaterialTheme.colorScheme.secondary) } } @@ -484,55 +468,55 @@ private fun DefaultView( LazyColumn( modifier = Modifier.fillMaxWidth(), - contentPadding = PaddingValues(bottom = contentPadding.calculateBottomPadding()) - ) { - if (showSortChip) { - item { SortChip(sortType = sortType, onClick = sortChipClick) } - } + contentPadding = PaddingValues(bottom = contentPadding.calculateBottomPadding())) { + if (showSortChip) { + item { SortChip(sortType = sortType, onClick = sortChipClick) } + } - if (viewType == ViewType.Split) { - item { - Row( - modifier = Modifier.fillMaxWidth().padding(horizontal = 16.dp), - verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.SpaceBetween, - ) { - graph(chartWidth = chartWidth, modifier = Modifier) - Column( - Modifier.fillMaxWidth(.9f).padding(16.dp), + if (viewType == ViewType.Split) { + item { + Row( + modifier = Modifier.fillMaxWidth().padding(horizontal = 16.dp), + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.SpaceBetween, ) { - sortedSeries.forEach { entry -> - StatCard( - header = entry.key, - headerColor = colorMap[entry.key]!!, - count = entry.value.size, - totalCount = totalCount, - readChapters = entry.value.sumOf { stat -> stat.readChapters }, - totalChapters = entry.value.sumOf { stat -> stat.totalChapters }, - readDuration = entry.value.sumOf { stat -> stat.readDuration }, - totalReadDuration = totalDuration, - ) + graph(chartWidth = chartWidth, modifier = Modifier) + Column( + Modifier.fillMaxWidth(.9f).padding(16.dp), + ) { + sortedSeries.forEach { entry -> + StatCard( + header = entry.key, + headerColor = colorMap[entry.key]!!, + count = entry.value.size, + totalCount = totalCount, + readChapters = entry.value.sumOf { stat -> stat.readChapters }, + totalChapters = + entry.value.sumOf { stat -> stat.totalChapters }, + readDuration = entry.value.sumOf { stat -> stat.readDuration }, + totalReadDuration = totalDuration, + ) + } } } } - } - } else { - item { graph(chartWidth = chartWidth, modifier = Modifier.fillMaxWidth()) } - item { Gap(Size.small) } - items(sortedSeries, key = { it.key }) { entry -> - StatCard( - header = entry.key, - headerColor = colorMap[entry.key]!!, - count = entry.value.size, - totalCount = totalCount, - readChapters = entry.value.sumOf { stat -> stat.readChapters }, - totalChapters = entry.value.sumOf { stat -> stat.totalChapters }, - readDuration = entry.value.sumOf { stat -> stat.readDuration }, - totalReadDuration = totalDuration, - ) + } else { + item { graph(chartWidth = chartWidth, modifier = Modifier.fillMaxWidth()) } + item { Gap(Size.small) } + items(sortedSeries, key = { it.key }) { entry -> + StatCard( + header = entry.key, + headerColor = colorMap[entry.key]!!, + count = entry.value.size, + totalCount = totalCount, + readChapters = entry.value.sumOf { stat -> stat.readChapters }, + totalChapters = entry.value.sumOf { stat -> stat.totalChapters }, + readDuration = entry.value.sumOf { stat -> stat.readDuration }, + totalReadDuration = totalDuration, + ) + } } } - } } @Composable @@ -573,41 +557,39 @@ private fun StatCardView( contentPadding = contentPadding, showSortChip = showSortChip, sortType = sortType, - sortChipClick = sortChipClick - ) { - items(sortedSeries, key = { it.first }) { entry -> - StatCard( - header = entry.first.capitalizeWords(), - headerColor = color, - count = entry.second.size, - totalCount = totalCount, - readChapters = entry.second.sumOf { stat -> stat.readChapters }, - totalChapters = entry.second.sumOf { stat -> stat.totalChapters }, - readDuration = entry.second.sumOf { stat -> stat.readDuration }, - totalReadDuration = totalReadDuration, - ) + sortChipClick = sortChipClick) { + items(sortedSeries, key = { it.first }) { entry -> + StatCard( + header = entry.first.capitalizeWords(), + headerColor = color, + count = entry.second.size, + totalCount = totalCount, + readChapters = entry.second.sumOf { stat -> stat.readChapters }, + totalChapters = entry.second.sumOf { stat -> stat.totalChapters }, + readDuration = entry.second.sumOf { stat -> stat.readDuration }, + totalReadDuration = totalReadDuration, + ) + } } - } } else { LazyListWrapper( contentPadding = contentPadding, showSortChip = showSortChip, sortType = sortType, - sortChipClick = sortChipClick - ) { - items(sortedSeries, key = { it.first }) { entry -> - StatCard( - header = entry.first.capitalizeWords(), - headerColor = color, - count = entry.second.size, - totalCount = totalCount, - readChapters = entry.second.sumOf { stat -> stat.readChapters }, - totalChapters = entry.second.sumOf { stat -> stat.totalChapters }, - readDuration = entry.second.sumOf { stat -> stat.readDuration }, - totalReadDuration = totalReadDuration, - ) + sortChipClick = sortChipClick) { + items(sortedSeries, key = { it.first }) { entry -> + StatCard( + header = entry.first.capitalizeWords(), + headerColor = color, + count = entry.second.size, + totalCount = totalCount, + readChapters = entry.second.sumOf { stat -> stat.readChapters }, + totalChapters = entry.second.sumOf { stat -> stat.totalChapters }, + readDuration = entry.second.sumOf { stat -> stat.readDuration }, + totalReadDuration = totalReadDuration, + ) + } } - } } } @@ -621,15 +603,14 @@ private fun LazyGridWrapper( ) { LazyVerticalGrid( columns = GridCells.Adaptive(400.dp), - contentPadding = PaddingValues(bottom = contentPadding.calculateBottomPadding()) - ) { - if (showSortChip) { - item(span = { GridItemSpan(maxCurrentLineSpan) }) { - SortChip(sortType = sortType, onClick = sortChipClick) + contentPadding = PaddingValues(bottom = contentPadding.calculateBottomPadding())) { + if (showSortChip) { + item(span = { GridItemSpan(maxCurrentLineSpan) }) { + SortChip(sortType = sortType, onClick = sortChipClick) + } } + content() } - content() - } } @Composable @@ -642,13 +623,12 @@ private fun LazyListWrapper( ) { LazyColumn( modifier = Modifier.fillMaxWidth(), - contentPadding = PaddingValues(bottom = contentPadding.calculateBottomPadding()) - ) { - if (showSortChip) { - item { SortChip(sortType = sortType, onClick = sortChipClick) } + contentPadding = PaddingValues(bottom = contentPadding.calculateBottomPadding())) { + if (showSortChip) { + item { SortChip(sortType = sortType, onClick = sortChipClick) } + } + content() } - content() - } } @Composable @@ -697,20 +677,17 @@ private fun DetailedCard(manga: StatsConstants.DetailedStatManga, modifier: Modi Text( text = manga.title, style = MaterialTheme.typography.titleMedium, - color = MaterialTheme.colorScheme.primary - ) + color = MaterialTheme.colorScheme.primary) Row( modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween, ) { Line( stringResource(id = R.string.typeNoSemi), - stringResource(id = manga.type.typeRes) - ) + stringResource(id = manga.type.typeRes)) Line( stringResource(id = R.string.status), - stringResource(id = manga.status.statusRes) - ) + stringResource(id = manga.status.statusRes)) } Row( modifier = Modifier.fillMaxWidth(), @@ -718,21 +695,17 @@ private fun DetailedCard(manga: StatsConstants.DetailedStatManga, modifier: Modi ) { Line( stringResource(id = R.string.read_duration), - manga.readDuration.getReadDuration(stringResource(id = R.string.none)) - ) + manga.readDuration.getReadDuration(stringResource(id = R.string.none))) Line( stringResource(id = R.string.start_year), - manga.startYear?.toString() ?: stringResource(id = R.string.n_a) - ) + manga.startYear?.toString() ?: stringResource(id = R.string.n_a)) } Line( stringResource(id = R.string.read_chapter_count), - manga.readChapters.toString() + " / " + manga.totalChapters.toString() - ) + manga.readChapters.toString() + " / " + manga.totalChapters.toString()) Line( stringResource(id = R.string.chapters_bookmarked), - manga.bookmarkedChapters.toString() - ) + manga.bookmarkedChapters.toString()) Line(stringResource(id = R.string.categories), manga.categories.joinToString(", ")) } @@ -743,21 +716,18 @@ private fun DetailedCard(manga: StatsConstants.DetailedStatManga, modifier: Modi private fun Line(label: String, value: String) { Row( horizontalArrangement = Arrangement.spacedBy(Size.small), - verticalAlignment = Alignment.CenterVertically - ) { - Text( - text = "$label:", - style = - MaterialTheme.typography.bodySmall.copy( - fontWeight = FontWeight.SemiBold, - color = - MaterialTheme.colorScheme.onSurface.copy( - alpha = NekoColors.mediumAlphaHighContrast - ) - ), - ) - Text(text = value, style = MaterialTheme.typography.bodyMedium) - } + verticalAlignment = Alignment.CenterVertically) { + Text( + text = "$label:", + style = + MaterialTheme.typography.bodySmall.copy( + fontWeight = FontWeight.SemiBold, + color = + MaterialTheme.colorScheme.onSurface.copy( + alpha = NekoColors.mediumAlphaHighContrast)), + ) + Text(text = value, style = MaterialTheme.typography.bodyMedium) + } } @Composable @@ -844,52 +814,46 @@ private fun StatCard( fontWeight = FontWeight.SemiBold, color = MaterialTheme.colorScheme.onSurface.copy( - alpha = NekoColors.mediumAlphaHighContrast - ) - ) + alpha = NekoColors.mediumAlphaHighContrast)) val valueStyle = MaterialTheme.typography.bodyMedium val headerStyle = MaterialTheme.typography.titleMedium.copy( - fontWeight = FontWeight.Bold, - color = headerColor - ) + fontWeight = FontWeight.Bold, color = headerColor) Column(modifier = Modifier.padding(horizontal = 12.dp, vertical = Size.small)) { Text(text = header, style = headerStyle, modifier = Modifier.fillMaxWidth()) Row( modifier = Modifier.fillMaxWidth(), - horizontalArrangement = Arrangement.SpaceBetween - ) { - Column(horizontalAlignment = Alignment.CenterHorizontally) { - Text( - text = stringResource(id = R.string.count), - style = labelStyle, - ) - Text(text = count.toString(), style = valueStyle) - Text(text = percentage(count, totalCount), style = valueStyle) - } - Column(horizontalAlignment = Alignment.CenterHorizontally) { - Text( - text = stringResource(id = R.string.chapters_read), - style = labelStyle, - ) + horizontalArrangement = Arrangement.SpaceBetween) { + Column(horizontalAlignment = Alignment.CenterHorizontally) { + Text( + text = stringResource(id = R.string.count), + style = labelStyle, + ) + Text(text = count.toString(), style = valueStyle) + Text(text = percentage(count, totalCount), style = valueStyle) + } + Column(horizontalAlignment = Alignment.CenterHorizontally) { + Text( + text = stringResource(id = R.string.chapters_read), + style = labelStyle, + ) - Text(text = "$readChapters / $totalChapters", style = valueStyle) - Text(text = percentage(readChapters, totalChapters), style = valueStyle) - } - Column(horizontalAlignment = Alignment.CenterHorizontally) { - Text( - text = stringResource(id = R.string.read_duration), - style = labelStyle, - ) + Text(text = "$readChapters / $totalChapters", style = valueStyle) + Text(text = percentage(readChapters, totalChapters), style = valueStyle) + } + Column(horizontalAlignment = Alignment.CenterHorizontally) { + Text( + text = stringResource(id = R.string.read_duration), + style = labelStyle, + ) - Text( - text = readDuration.getReadDuration(stringResource(id = R.string.none)), - style = valueStyle - ) - Text(text = percentage(readDuration, totalReadDuration), style = valueStyle) + Text( + text = readDuration.getReadDuration(stringResource(id = R.string.none)), + style = valueStyle) + Text(text = percentage(readDuration, totalReadDuration), style = valueStyle) + } } - } } } } diff --git a/app/src/main/java/org/nekomanga/presentation/screens/stats/SimpleStats.kt b/app/src/main/java/org/nekomanga/presentation/screens/stats/SimpleStats.kt index 46f5c9c4d3..dbbc5c5fc1 100644 --- a/app/src/main/java/org/nekomanga/presentation/screens/stats/SimpleStats.kt +++ b/app/src/main/java/org/nekomanga/presentation/screens/stats/SimpleStats.kt @@ -91,27 +91,26 @@ fun SimpleStats( LazyColumn( modifier = Modifier.fillMaxSize(), contentPadding = contentPadding, - verticalArrangement = verticalArrangement - ) { - val axisPadding = - when (isTablet) { - true -> 16.dp - false -> Size.small - } - - item { - FlowRow( - modifier = Modifier.fillMaxWidth().padding(Size.medium), - horizontalArrangement = - Arrangement.spacedBy(axisPadding, Alignment.CenterHorizontally), - verticalArrangement = Arrangement.spacedBy(axisPadding, Alignment.CenterVertically) - ) { - stats.forEach { - BasicStat(value = it.first, label = it.second, isTablet = isTablet) + verticalArrangement = verticalArrangement) { + val axisPadding = + when (isTablet) { + true -> 16.dp + false -> Size.small } + + item { + FlowRow( + modifier = Modifier.fillMaxWidth().padding(Size.medium), + horizontalArrangement = + Arrangement.spacedBy(axisPadding, Alignment.CenterHorizontally), + verticalArrangement = + Arrangement.spacedBy(axisPadding, Alignment.CenterVertically)) { + stats.forEach { + BasicStat(value = it.first, label = it.second, isTablet = isTablet) + } + } } } - } } @Composable @@ -122,14 +121,12 @@ private fun BasicStat(value: String, label: String, isTablet: Boolean) { Triple( MaterialTheme.typography.headlineLarge.copy(fontWeight = FontWeight.SemiBold), MaterialTheme.typography.titleMedium, - 20.dp - ) + 20.dp) false -> Triple( MaterialTheme.typography.titleLarge.copy(fontWeight = FontWeight.SemiBold), MaterialTheme.typography.labelMedium, - 12.dp - ) + 12.dp) } ElevatedCard( @@ -140,8 +137,7 @@ private fun BasicStat(value: String, label: String, isTablet: Boolean) { Text( text = value, style = titleTypography, - color = MaterialTheme.colorScheme.primary - ) + color = MaterialTheme.colorScheme.primary) Text(text = label, style = labelTypography) } } diff --git a/core/src/main/kotlin/tachiyomi/core/network/ProgressResponseBody.kt b/core/src/main/kotlin/tachiyomi/core/network/ProgressResponseBody.kt index aba39debf0..a455e55ac4 100644 --- a/core/src/main/kotlin/tachiyomi/core/network/ProgressResponseBody.kt +++ b/core/src/main/kotlin/tachiyomi/core/network/ProgressResponseBody.kt @@ -38,10 +38,7 @@ class ProgressResponseBody( // read() returns the number of bytes read, or -1 if this source is exhausted. totalBytesRead += if (bytesRead != -1L) bytesRead else 0 progressListener.update( - totalBytesRead, - responseBody.contentLength(), - bytesRead == -1L - ) + totalBytesRead, responseBody.contentLength(), bytesRead == -1L) return bytesRead } } diff --git a/core/src/main/kotlin/tachiyomi/core/network/interceptors/WebViewInterceptor.kt b/core/src/main/kotlin/tachiyomi/core/network/interceptors/WebViewInterceptor.kt index 166d0b9910..2cc055dea7 100644 --- a/core/src/main/kotlin/tachiyomi/core/network/interceptors/WebViewInterceptor.kt +++ b/core/src/main/kotlin/tachiyomi/core/network/interceptors/WebViewInterceptor.kt @@ -33,10 +33,8 @@ abstract class WebViewInterceptor( // Crashes on some devices. We skip this in some cases since the only impact is slower // WebView init in those rare cases. // See https://bugs.chromium.org/p/chromium/issues/detail?id=1279562 - if ( - DeviceUtil.isMiui || - Build.VERSION.SDK_INT == Build.VERSION_CODES.S && DeviceUtil.isSamsung - ) { + if (DeviceUtil.isMiui || + Build.VERSION.SDK_INT == Build.VERSION_CODES.S && DeviceUtil.isSamsung) { return@lazy } @@ -108,5 +106,4 @@ private val unsafeHeaderNames = "cookie2", "keep-alive", "transfer-encoding", - "set-cookie" - ) + "set-cookie") diff --git a/core/src/main/kotlin/tachiyomi/core/util/storage/AndroidStorageProvider.kt b/core/src/main/kotlin/tachiyomi/core/util/storage/AndroidStorageProvider.kt index 294fa35d86..5ff8da737c 100644 --- a/core/src/main/kotlin/tachiyomi/core/util/storage/AndroidStorageProvider.kt +++ b/core/src/main/kotlin/tachiyomi/core/util/storage/AndroidStorageProvider.kt @@ -18,8 +18,7 @@ class AndroidStorageFolderProvider( when (BuildConfig.DEBUG) { true -> context.getString(R.string.app_name) + "_debug" false -> context.getString(R.string.app_name) - } - ) + }) } override fun path(): String {