diff --git a/.editorconfig b/.editorconfig index f114aa5bb..0c3e29daa 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,5 +1,7 @@ [*.{kt,kts}] ij_kotlin_imports_layout = * +ij_kotlin_line_break_after_multiline_when_entry = false ktlint_code_style = intellij_idea ktlint_function_naming_ignore_when_annotated_with = Composable ktlint_standard_class-signature = disabled +ktlint_standard_mixed-condition-operators = disabled diff --git a/app/src/main/kotlin/com/google/accompanist/web/WebView.kt b/app/src/main/kotlin/com/google/accompanist/web/WebView.kt index b0d5cf0ff..7b67bc57e 100644 --- a/app/src/main/kotlin/com/google/accompanist/web/WebView.kt +++ b/app/src/main/kotlin/com/google/accompanist/web/WebView.kt @@ -180,7 +180,6 @@ fun WebView( is WebContent.Url -> { wv.loadUrl(content.url, content.additionalHttpHeaders) } - is WebContent.Data -> { wv.loadDataWithBaseURL( content.baseUrl, @@ -190,14 +189,12 @@ fun WebView( content.historyUrl, ) } - is WebContent.Post -> { wv.postUrl( content.url, content.postData, ) } - is WebContent.NavigatorOnly -> { // NO-OP } @@ -502,11 +499,9 @@ class WebViewNavigator(private val coroutineScope: CoroutineScope) { event.encoding, event.historyUrl, ) - is NavigationEvent.LoadUrl -> { loadUrl(event.url, event.additionalHttpHeaders) } - is NavigationEvent.PostUrl -> { postUrl(event.url, event.postData) } diff --git a/app/src/main/kotlin/com/hippo/ehviewer/client/data/ListUrlBuilder.kt b/app/src/main/kotlin/com/hippo/ehviewer/client/data/ListUrlBuilder.kt index 93f4a2568..21b187d45 100644 --- a/app/src/main/kotlin/com/hippo/ehviewer/client/data/ListUrlBuilder.kt +++ b/app/src/main/kotlin/com/hippo/ehviewer/client/data/ListUrlBuilder.kt @@ -212,7 +212,6 @@ data class ListUrlBuilder( } } }.buildString() - MODE_UPLOADER, MODE_TAG -> { val path = if (mode == MODE_UPLOADER) "uploader" else "tag" ehUrl(listOf(path, requireNotNull(mKeyword))) { @@ -222,7 +221,6 @@ data class ListUrlBuilder( addQueryParameterIfNotBlank("range", range.takeIf { it > 0 }?.toString()) }.buildString() } - MODE_WHATS_HOT -> EhUrl.popularUrl MODE_IMAGE_SEARCH -> ehUrl { addQueryParameter("f_shash", requireNotNull(hash)) @@ -231,7 +229,6 @@ data class ListUrlBuilder( addQueryParameter("tl", requireNotNull(mKeyword)) addQueryParameterIfNotBlank("p", jumpTo) }.buildString() - else -> throw IllegalStateException("Unexpected value: $mode") } diff --git a/app/src/main/kotlin/com/hippo/ehviewer/client/parser/GalleryListUrlParser.kt b/app/src/main/kotlin/com/hippo/ehviewer/client/parser/GalleryListUrlParser.kt index a1143d0aa..7d0a59945 100644 --- a/app/src/main/kotlin/com/hippo/ehviewer/client/parser/GalleryListUrlParser.kt +++ b/app/src/main/kotlin/com/hippo/ehviewer/client/parser/GalleryListUrlParser.kt @@ -42,7 +42,6 @@ object GalleryListUrlParser { mode = if (head == "uploader") ListUrlBuilder.MODE_UPLOADER else ListUrlBuilder.MODE_TAG keyword = segments[1].decodeURLQueryComponent(plusIsSpace = true) } - "toplist.php" -> { val tl = url.parameters["tl"] if (tl != null && tl in arrayOf("11", "12", "13", "15")) { @@ -55,7 +54,6 @@ object GalleryListUrlParser { null } } - else -> { val category = EhUtils.getCategory(head) if (category != EhUtils.UNKNOWN) { diff --git a/app/src/main/kotlin/com/hippo/ehviewer/download/DownloadService.kt b/app/src/main/kotlin/com/hippo/ehviewer/download/DownloadService.kt index c1cd6c658..f020aa39e 100644 --- a/app/src/main/kotlin/com/hippo/ehviewer/download/DownloadService.kt +++ b/app/src/main/kotlin/com/hippo/ehviewer/download/DownloadService.kt @@ -113,14 +113,12 @@ class DownloadService : val label = intent.getStringExtra(KEY_LABEL) deferredMgr.await().startDownload(decodeFromSavedState(gi), label) } - ACTION_START_RANGE -> { val gidList = intent.getLongArrayExtra(KEY_GID_LIST) if (gidList != null) { deferredMgr.await().startRangeDownload(gidList) } } - ACTION_START_ALL -> deferredMgr.await().startAllDownload() ACTION_STOP_ALL -> deferredMgr.await().stopAllDownload() ACTION_CLEAR -> clear() @@ -388,7 +386,6 @@ class DownloadService : notifyManager.notify(id, builder.build()) } } - Ops.Cancel -> notifyManager.cancel(id) Ops.StartForeground -> service.startForeground(id, builder.build()) } diff --git a/app/src/main/kotlin/com/hippo/ehviewer/image/Image.kt b/app/src/main/kotlin/com/hippo/ehviewer/image/Image.kt index a95e8a892..dd3af861c 100644 --- a/app/src/main/kotlin/com/hippo/ehviewer/image/Image.kt +++ b/app/src/main/kotlin/com/hippo/ehviewer/image/Image.kt @@ -130,7 +130,6 @@ class Image private constructor(image: CoilImage, private val src: ImageSource) } src.right().decodeCoil(checkExtraneousAds) } - is ByteBufferSource -> { if (isAtLeastP && !isAtLeastU) { rewriteGifSource(src.source) diff --git a/app/src/main/kotlin/com/hippo/ehviewer/spider/ComicInfo.kt b/app/src/main/kotlin/com/hippo/ehviewer/spider/ComicInfo.kt index c21d6bff5..7550063ac 100644 --- a/app/src/main/kotlin/com/hippo/ehviewer/spider/ComicInfo.kt +++ b/app/src/main/kotlin/com/hippo/ehviewer/spider/ComicInfo.kt @@ -68,7 +68,6 @@ fun GalleryInfo.getComicInfo(): ComicInfo { else -> Unit } } - else -> simpleTags?.forEach { tagString -> val (namespace, tag) = tagString.split(':', limit = 2) .takeIf { it.size == 2 } ?: return@forEach // Ignore temp tags that don't have namespace diff --git a/app/src/main/kotlin/com/hippo/ehviewer/spider/SpiderDen.kt b/app/src/main/kotlin/com/hippo/ehviewer/spider/SpiderDen.kt index 8db52e996..c0fdf7f8d 100644 --- a/app/src/main/kotlin/com/hippo/ehviewer/spider/SpiderDen.kt +++ b/app/src/main/kotlin/com/hippo/ehviewer/spider/SpiderDen.kt @@ -129,11 +129,9 @@ class SpiderDen(val info: GalleryInfo) { SpiderQueen.MODE_READ -> { containInCache(index) || containInDownloadDir(index) } - SpiderQueen.MODE_DOWNLOAD -> { containInDownloadDir(index) || copyFromCacheToDownloadDir(index) } - else -> { false } diff --git a/app/src/main/kotlin/com/hippo/ehviewer/ui/CommonOperations.kt b/app/src/main/kotlin/com/hippo/ehviewer/ui/CommonOperations.kt index d6d507a64..64d408c90 100644 --- a/app/src/main/kotlin/com/hippo/ehviewer/ui/CommonOperations.kt +++ b/app/src/main/kotlin/com/hippo/ehviewer/ui/CommonOperations.kt @@ -233,7 +233,6 @@ private suspend fun doModifyFavorites( } false } - LOCAL_FAVORITED -> { if (localFavorited) { EhDB.removeLocalFavorites(galleryInfo) @@ -248,7 +247,6 @@ private suspend fun doModifyFavorites( } !localFavorited } - in 0..9 -> { EhEngine.modifyFavorites(gid, token, slot, note) favoriteSlot = slot @@ -256,7 +254,6 @@ private suspend fun doModifyFavorites( favoriteNote = note true } - else -> throw EhException("Invalid favorite slot!") } FavouriteStatusRouter.notify(galleryInfo) @@ -305,13 +302,11 @@ suspend fun doGalleryInfoAction(info: BaseGalleryInfo) { EhDB.putHistoryInfo(info) navToReader(info) } - 1 -> if (downloaded) { confirmRemoveDownload(info) } else { startDownload(false, info) } - 2 -> if (favorited) { runSuspendCatching { removeFromFavorites(info) @@ -327,7 +322,6 @@ suspend fun doGalleryInfoAction(info: BaseGalleryInfo) { tip(R.string.add_to_favorite_failure) } } - 3 -> showMoveDownloadLabel(info) } } diff --git a/app/src/main/kotlin/com/hippo/ehviewer/ui/main/GalleryList.kt b/app/src/main/kotlin/com/hippo/ehviewer/ui/main/GalleryList.kt index 40186400e..813086562 100644 --- a/app/src/main/kotlin/com/hippo/ehviewer/ui/main/GalleryList.kt +++ b/app/src/main/kotlin/com/hippo/ehviewer/ui/main/GalleryList.kt @@ -207,7 +207,6 @@ fun GalleryList( } } } - is LoadState.Error -> { Surface { ErrorTip( @@ -216,7 +215,6 @@ fun GalleryList( ) } } - is LoadState.NotLoading -> if (data.itemCount == 0) { // Only for local favorites as empty gallery lists from network are treated as error ErrorTip(modifier = Modifier.widthIn(max = 228.dp), text = stringResource(id = R.string.gallery_list_empty_hit)) diff --git a/app/src/main/kotlin/com/hippo/ehviewer/ui/main/LoadStateIndicator.kt b/app/src/main/kotlin/com/hippo/ehviewer/ui/main/LoadStateIndicator.kt index e43757dca..af006cc10 100644 --- a/app/src/main/kotlin/com/hippo/ehviewer/ui/main/LoadStateIndicator.kt +++ b/app/src/main/kotlin/com/hippo/ehviewer/ui/main/LoadStateIndicator.kt @@ -22,7 +22,6 @@ fun LoadStateIndicator( is LoadState.Loading -> { LinearWavyProgressIndicator(modifier = modifier) } - is LoadState.Error -> { Column(modifier = modifier, horizontalAlignment = Alignment.CenterHorizontally) { Text(text = state.error.displayString()) @@ -31,6 +30,5 @@ fun LoadStateIndicator( } } } - is LoadState.NotLoading -> Unit } diff --git a/app/src/main/kotlin/com/hippo/ehviewer/ui/reader/PagerViewer.kt b/app/src/main/kotlin/com/hippo/ehviewer/ui/reader/PagerViewer.kt index 6c328f1a4..31cb99bcf 100644 --- a/app/src/main/kotlin/com/hippo/ehviewer/ui/reader/PagerViewer.kt +++ b/app/src/main/kotlin/com/hippo/ehviewer/ui/reader/PagerViewer.kt @@ -204,20 +204,17 @@ private fun PageContainer( moveToNext() } } - NavigationRegion.PREV -> { val canPan = if (isRtl) panLeft(distance, bounds) else panRight(distance, bounds) if (!canPan) { moveToPrevious() } } - NavigationRegion.RIGHT -> { if (!panLeft(distance, bounds)) { if (isRtl) moveToPrevious() else moveToNext() } } - NavigationRegion.LEFT -> { if (!panRight(distance, bounds)) { if (isRtl) moveToNext() else moveToPrevious() diff --git a/app/src/main/kotlin/com/hippo/ehviewer/ui/screen/GalleryDetailContent.kt b/app/src/main/kotlin/com/hippo/ehviewer/ui/screen/GalleryDetailContent.kt index c6e46689c..37586d287 100644 --- a/app/src/main/kotlin/com/hippo/ehviewer/ui/screen/GalleryDetailContent.kt +++ b/app/src/main/kotlin/com/hippo/ehviewer/ui/screen/GalleryDetailContent.kt @@ -320,7 +320,6 @@ fun GalleryDetailContent( galleryPreview(galleryDetail, previews) { navToReader(galleryDetail.galleryInfo, it) } } } - else -> FastScrollLazyVerticalGrid( columns = GridCells.Fixed(thumbColumns), contentPadding = contentPadding, diff --git a/core/ui/src/commonMain/kotlin/androidx/compose/foundation/gestures/HorizontalDraggable.kt b/core/ui/src/commonMain/kotlin/androidx/compose/foundation/gestures/HorizontalDraggable.kt index d22463302..6cac7f75d 100644 --- a/core/ui/src/commonMain/kotlin/androidx/compose/foundation/gestures/HorizontalDraggable.kt +++ b/core/ui/src/commonMain/kotlin/androidx/compose/foundation/gestures/HorizontalDraggable.kt @@ -86,6 +86,7 @@ internal abstract class HorizontalDragGestureNode( private fun startListeningForEvents() { isListeningForEvents = true + @Suppress("ktlint:standard:kdoc") /** * To preserve the original behavior we had (before the Modifier.Node migration) we need to * scope the DragStopped and DragCancel methods to the node's coroutine scope instead of using diff --git a/core/ui/src/commonMain/kotlin/androidx/compose/material3/fork/DraggableAnchors.kt b/core/ui/src/commonMain/kotlin/androidx/compose/material3/fork/DraggableAnchors.kt index 80fda71ec..87b88d084 100644 --- a/core/ui/src/commonMain/kotlin/androidx/compose/material3/fork/DraggableAnchors.kt +++ b/core/ui/src/commonMain/kotlin/androidx/compose/material3/fork/DraggableAnchors.kt @@ -14,6 +14,8 @@ * limitations under the License. */ +@file:Suppress("ktlint:standard:kdoc") + package androidx.compose.material3.fork /** diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index b6f1ed5b1..4ca26353e 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -97,7 +97,7 @@ kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutine kotlinx-datetime = { module = "org.jetbrains.kotlinx:kotlinx-datetime", version.ref = "kotlinx-datetime" } kotlinx-io = { module = "org.jetbrains.kotlinx:kotlinx-io-core", version.ref = "kotlinx-io" } -ktlint = "com.pinterest.ktlint:ktlint-cli:1.7.1" +ktlint = "com.pinterest.ktlint:ktlint-cli:1.8.0" okhttp-bom = { module = "com.squareup.okhttp3:okhttp-bom", version.ref = "okhttp" } ktor-client-okhttp = { module = "io.ktor:ktor-client-okhttp", version.ref = "ktor" }