Fix: ktlint config for SY code (#712)

* Add more editor configs and move ktlint config to it (mihonapp/mihon#1731)

(cherry picked from commit 34d1e6fa278846dd8eb6ea82c936818d4610d3c2)

* more ktlint config

* fix compile

* restore comment-wrapping

* restore all of them

* disable in gradle.kts

* cleanup

* remove filenamktlint_standard_filename

* fix filename

* remove unused EhAssets

* ktlint_standard_multiline-expression-wrapping

* property-naming & function-naming

* ktlint_standard_argument-list-wrapping

* fix argument-list-wrapping

* Improve  in case source is null

related to commit 343cd372

* comment

* comment

* comment

* comment

* comment

* comment

* comment

* comment

* Revert "Improve  in case source is null"

This reverts commit 08e317bb075b4b634f0c6f19f11eb78b99406e59.

* Revert "remove unused EhAssets"

This reverts commit e2cfc3e0c2b8d5b8bac41f2dfc4d9baef332f83e.

---------

Co-authored-by: AntsyLich <59261191+AntsyLich@users.noreply.github.com>
This commit is contained in:
Cuong-Tran 2025-02-18 13:44:57 +07:00 committed by GitHub
parent 56a15d1da6
commit 4c08f61f68
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
39 changed files with 124 additions and 69 deletions

View file

@ -26,3 +26,10 @@ ktlint_standard_class-signature = disabled
ktlint_standard_discouraged-comment-location = disabled
ktlint_standard_function-expression-body = disabled
ktlint_standard_function-signature = disabled
# Avoid ktlint format messy code from SY
ktlint_standard_max-line-length = disabled
ktlint_standard_comment-wrapping = disabled
ktlint_standard_type-argument-comment = disabled
ktlint_standard_value-argument-comment = disabled
ktlint_standard_value-parameter-comment = disabled

View file

@ -15,8 +15,10 @@ import tachiyomi.source.local.isLocal
*/
fun List<Chapter>.applyFilters(
manga: Manga,
downloadManager: DownloadManager, /* SY --> */
mergedManga: Map<Long, Manga>, /* SY <-- */
downloadManager: DownloadManager,
// SY -->
mergedManga: Map<Long, Manga>,
// SY <--
): List<Chapter> {
val isLocalManga = manga.isLocal()
val unreadFilter = manga.unreadFilter
@ -34,7 +36,9 @@ fun List<Chapter>.applyFilters(
val downloaded = downloadManager.isChapterDownloaded(
chapter.name,
chapter.scanlator,
/* SY --> */ manga.ogTitle /* SY <-- */,
// SY -->
manga.ogTitle,
// SY <--
manga.source,
)
downloaded || isLocalManga

View file

@ -42,7 +42,8 @@ fun SyncFavoritesProgressDialog(
text = context.stringResource(
SYMR.strings.favorites_sync_bad_library_state,
context.stringResource(
SYMR.strings.favorites_sync_gallery_in_multiple_categories, status.mangaTitle,
SYMR.strings.favorites_sync_gallery_in_multiple_categories,
status.mangaTitle,
status.categories.joinToString(),
),
),
@ -62,14 +63,10 @@ fun SyncFavoritesProgressDialog(
when (it) {
is FavoritesSyncStatus.SyncError.GallerySyncError.GalleryAddFail ->
context.stringResource(SYMR.strings.favorites_sync_failed_to_add_to_local) +
context.stringResource(
SYMR.strings.favorites_sync_failed_to_add_to_local_error, it.title, it.reason,
)
context.stringResource(SYMR.strings.favorites_sync_failed_to_add_to_local_error, it.title, it.reason)
is FavoritesSyncStatus.SyncError.GallerySyncError.InvalidGalleryFail ->
context.stringResource(SYMR.strings.favorites_sync_failed_to_add_to_local) +
context.stringResource(
SYMR.strings.favorites_sync_failed_to_add_to_local_unknown_type, it.title, it.url,
)
context.stringResource(SYMR.strings.favorites_sync_failed_to_add_to_local_unknown_type, it.title, it.url)
is FavoritesSyncStatus.SyncError.GallerySyncError.UnableToAddGalleryToRemote ->
context.stringResource(SYMR.strings.favorites_sync_unable_to_add_to_remote, it.title, it.gid)
FavoritesSyncStatus.SyncError.GallerySyncError.UnableToDeleteFromRemote ->
@ -100,14 +97,10 @@ fun SyncFavoritesProgressDialog(
context.stringResource(SYMR.strings.favorites_sync_unknown_error, status.message)
is FavoritesSyncStatus.SyncError.GallerySyncError.GalleryAddFail ->
context.stringResource(SYMR.strings.favorites_sync_failed_to_add_to_local) +
context.stringResource(
SYMR.strings.favorites_sync_failed_to_add_to_local_error, status.title, status.reason,
)
context.stringResource(SYMR.strings.favorites_sync_failed_to_add_to_local_error, status.title, status.reason)
is FavoritesSyncStatus.SyncError.GallerySyncError.InvalidGalleryFail ->
context.stringResource(SYMR.strings.favorites_sync_failed_to_add_to_local) +
context.stringResource(
SYMR.strings.favorites_sync_failed_to_add_to_local_unknown_type, status.title, status.url,
)
context.stringResource(SYMR.strings.favorites_sync_failed_to_add_to_local_unknown_type, status.title, status.url)
is FavoritesSyncStatus.SyncError.GallerySyncError.UnableToAddGalleryToRemote ->
context.stringResource(SYMR.strings.favorites_sync_unable_to_add_to_remote, status.title, status.gid)
FavoritesSyncStatus.SyncError.GallerySyncError.UnableToDeleteFromRemote ->

View file

@ -1,3 +1,5 @@
@file:Suppress("PropertyName")
package eu.kanade.presentation.manga.components
import androidx.annotation.ColorInt

View file

@ -1,3 +1,5 @@
@file:Suppress("FunctionName")
package eu.kanade.presentation.manga.components
import androidx.compose.foundation.clickable

View file

@ -1,3 +1,5 @@
@file:Suppress("PropertyName")
package eu.kanade.presentation.more.settings.screen.about
import androidx.compose.foundation.layout.Arrangement

View file

@ -48,7 +48,8 @@ class MangaBackupCreator(
getCustomMangaInfo.get(manga.id)
} else {
null
}, /* SY <-- */
},
// SY <--
)
// SY -->

View file

@ -27,7 +27,9 @@ class CategoriesRestorer(
val order = nextOrder++
handler.awaitOneExecutable {
categoriesQueries.insert(
it.name, order, it.flags,
it.name,
order,
it.flags,
// KMK -->
hidden = if (it.hidden) 1L else 0L,
// KMK <--

View file

@ -124,7 +124,8 @@ class PagePreviewFetcher(
private suspend fun executeNetworkRequest(): Response {
val response = sourceLazy.value?.fetchPreviewImage(
page.getPagePreviewInfo(), getCacheControl(),
page.getPagePreviewInfo(),
getCacheControl(),
) ?: callFactoryLazy.value.newCall(newRequest()).await()
if (!response.isSuccessful && response.code != HTTP_NOT_MODIFIED) {
response.close()

View file

@ -247,7 +247,9 @@ class DownloadCache(
val sourceDir = rootDownloadsDir.sourceDirs[manga.source] ?: return
val mangaDir = sourceDir.mangaDirs[
provider.getMangaDirName(
/* SY --> */ manga.ogTitle, /* SY <-- */
// SY -->
manga.ogTitle,
// SY <--
),
] ?: return
provider.getValidChapterDirNames(chapter.name, chapter.scanlator).forEach {
@ -286,7 +288,9 @@ class DownloadCache(
val sourceDir = rootDownloadsDir.sourceDirs[manga.source] ?: return
val mangaDir = sourceDir.mangaDirs[
provider.getMangaDirName(
/* SY --> */ manga.ogTitle, /* SY <-- */
// SY -->
manga.ogTitle,
// SY <--
),
] ?: return
chapters.forEach { chapter ->

View file

@ -167,7 +167,9 @@ class DownloadManager(
val chapterDir = provider.findChapterDir(
chapter.name,
chapter.scanlator,
/* SY --> */ manga.ogTitle /* SY <-- */,
// SY -->
manga.ogTitle,
// SY <--
source,
)
val files = chapterDir?.listFiles().orEmpty()

View file

@ -628,7 +628,9 @@ class LibraryUpdateJob(private val context: Context, workerParams: WorkerParamet
count++
notifier.showProgressNotification(
listOf(Manga.create().copy(ogTitle = networkManga.title)), count, size,
listOf(Manga.create().copy(ogTitle = networkManga.title)),
count,
size,
)
var dbManga = getManga.await(networkManga.url, mangaDex.id)

View file

@ -1,3 +1,5 @@
@file:Suppress("PropertyName")
package eu.kanade.tachiyomi.source
import android.content.Context

View file

@ -1,3 +1,5 @@
@file:Suppress("PropertyName")
package eu.kanade.tachiyomi.source.online.all
import android.content.Context

View file

@ -1,3 +1,5 @@
@file:Suppress("PropertyName")
package eu.kanade.tachiyomi.ui.browse.feed
import androidx.compose.runtime.Composable

View file

@ -1240,7 +1240,9 @@ class ReaderActivity : BaseActivity() {
// SY -->
val text = if (secondPage != null) {
stringResource(
SYMR.strings.share_pages_info, manga.title, chapter.name,
SYMR.strings.share_pages_info,
manga.title,
chapter.name,
if (resources.configuration.layoutDirection ==
View.LAYOUT_DIRECTION_LTR
) {

View file

@ -370,7 +370,7 @@ class ReaderViewModel @JvmOverloads constructor(
mutableState.update {
it.copy(
manga = manga,
/* SY --> */
// SY -->
meta = metadata,
mergedManga = mergedManga,
dateRelativeTime = relativeTime,
@ -380,7 +380,7 @@ class ReaderViewModel @JvmOverloads constructor(
autoScrollFreq.toString()
},
isAutoScrollEnabled = autoScrollFreq != -1f,
/* SY <-- */
// SY <--
)
}
if (chapterId == -1L) chapterId = initialChapterId
@ -392,17 +392,21 @@ class ReaderViewModel @JvmOverloads constructor(
downloadManager = downloadManager,
downloadProvider = downloadProvider,
manga = manga,
source = source, /* SY --> */
source = source,
// SY -->
sourceManager = sourceManager,
readerPrefs = readerPreferences,
mergedReferences = mergedReferences,
mergedManga = mergedManga, /* SY <-- */
mergedManga = mergedManga,
// SY <--
)
loadChapter(
loader!!,
chapterList.first { chapterId == it.chapter.id },
/* SY --> */page, /* SY <-- */
// SY -->
page,
// SY <--
)
Result.success(true)
} else {
@ -538,7 +542,9 @@ class ReaderViewModel @JvmOverloads constructor(
val isDownloaded = downloadManager.isChapterDownloaded(
dbChapter.name,
dbChapter.scanlator,
/* SY --> */ manga.ogTitle /* SY <-- */,
// SY -->
manga.ogTitle,
// SY <--
manga.source,
skipCache = true,
)
@ -677,8 +683,10 @@ class ReaderViewModel @JvmOverloads constructor(
*/
private suspend fun updateChapterProgress(
readerChapter: ReaderChapter,
page: Page/* SY --> */,
hasExtraPage: Boolean, /* SY <-- */
page: Page,
// SY -->
hasExtraPage: Boolean,
// SY <--
) {
val pageIndex = page.index
val syncTriggerOpt = syncPreferences.getSyncTriggerOptions()
@ -1378,8 +1386,10 @@ class ReaderViewModel @JvmOverloads constructor(
// SY <--
data class PageActions(
val page: ReaderPage/* SY --> */,
val extraPage: ReaderPage? = null, /* SY <-- */
val page: ReaderPage,
// SY -->
val extraPage: ReaderPage? = null,
// SY <--
) : Dialog
// SY -->
@ -1398,8 +1408,10 @@ class ReaderViewModel @JvmOverloads constructor(
data class SavedImage(val result: SaveImageResult) : Event
data class ShareImage(
val uri: Uri,
val page: ReaderPage/* SY --> */,
val secondPage: ReaderPage? = null, /* SY <-- */
val page: ReaderPage,
// SY -->
val secondPage: ReaderPage? = null,
// SY <--
) : Event
data class CopyImage(val uri: Uri) : Event
}

View file

@ -94,8 +94,10 @@ class ChapterLoader(
val dbChapter = chapter.chapter
val isDownloaded = downloadManager.isChapterDownloaded(
chapterName = dbChapter.name,
chapterScanlator = dbChapter.scanlator, /* SY --> */
mangaTitle = manga.ogTitle /* SY <-- */,
chapterScanlator = dbChapter.scanlator,
// SY -->
mangaTitle = manga.ogTitle,
// SY <--
sourceId = manga.source,
skipCache = true,
)

View file

@ -12,8 +12,10 @@ import tachiyomi.domain.manga.model.Manga
*/
fun List<Chapter>.getNextUnread(
manga: Manga,
downloadManager: DownloadManager /* SY --> */,
mergedManga: Map<Long, Manga>, /* SY <-- */
downloadManager: DownloadManager,
// SY -->
mergedManga: Map<Long, Manga>,
// SY <--
): Chapter? {
return applyFilters(manga, downloadManager/* SY --> */, mergedManga/* SY <-- */).let { chapters ->
// SY -->

View file

@ -4,6 +4,7 @@ import android.graphics.Color
import dev.icerock.moko.resources.StringResource
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.track.Tracker
import eu.kanade.tachiyomi.data.track.model.TrackMangaMetadata
import eu.kanade.tachiyomi.data.track.model.TrackSearch
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.toImmutableList
@ -121,10 +122,8 @@ data class DummyTracker(
) = Unit
override suspend fun getMangaMetadata(
track: tachiyomi.domain.track.model.Track,
): eu.kanade.tachiyomi.data.track.model.TrackMangaMetadata = eu.kanade.tachiyomi.data.track.model.TrackMangaMetadata(
0, "test", "test", "test", "test", "test",
)
track: Track,
): TrackMangaMetadata = TrackMangaMetadata(0, "test", "test", "test", "test", "test")
// KMK -->
override fun hasNotStartedReading(status: Long): Boolean = status == 2L

View file

@ -400,15 +400,9 @@ class FavoritesSyncHelper(val context: Context) {
}
val error = when (result) {
is GalleryAddEvent.Fail.Error -> FavoritesSyncStatus.SyncError.GallerySyncError.GalleryAddFail(
it.title, result.logMessage,
)
is GalleryAddEvent.Fail.UnknownType -> FavoritesSyncStatus.SyncError.GallerySyncError.InvalidGalleryFail(
it.title, result.galleryUrl,
)
is GalleryAddEvent.Fail.UnknownSource -> FavoritesSyncStatus.SyncError.GallerySyncError.InvalidGalleryFail(
it.title, result.galleryUrl,
)
is GalleryAddEvent.Fail.Error -> FavoritesSyncStatus.SyncError.GallerySyncError.GalleryAddFail(it.title, result.logMessage)
is GalleryAddEvent.Fail.UnknownType -> FavoritesSyncStatus.SyncError.GallerySyncError.InvalidGalleryFail(it.title, result.galleryUrl)
is GalleryAddEvent.Fail.UnknownSource -> FavoritesSyncStatus.SyncError.GallerySyncError.InvalidGalleryFail(it.title, result.galleryUrl)
}
if (prefs.exhLenientSync().get()) {

View file

@ -34,7 +34,8 @@ class SimilarHandler(
}
return MetadataMangasPage(
mangaList, false,
mangaList,
false,
List(mangaList.size) {
MangaDexSearchMetadata().also { it.relation = MangaDexRelation.SIMILAR }
},

View file

@ -1,3 +1,5 @@
@file:Suppress("PropertyName")
package exh.md.utils
object MdApi {

View file

@ -1,3 +1,5 @@
@file:Suppress("PropertyName")
package exh.md.utils
import android.util.Base64

View file

@ -1,3 +1,5 @@
@file:Suppress("PropertyName")
package exh.md.utils
import android.app.Application

View file

@ -22,7 +22,9 @@ import tachiyomi.domain.manga.model.Manga
import tachiyomi.i18n.sy.SYMR
class AniListPagingSource(manga: Manga, source: CatalogueSource?) : TrackerRecommendationPagingSource(
"https://graphql.anilist.co/", source, manga,
"https://graphql.anilist.co/",
source,
manga,
) {
override val name: String
get() = "AniList"

View file

@ -24,7 +24,9 @@ import tachiyomi.domain.manga.model.Manga
import tachiyomi.i18n.sy.SYMR
abstract class MangaUpdatesPagingSource(manga: Manga, source: CatalogueSource?) : TrackerRecommendationPagingSource(
"https://api.mangaupdates.com/v1/", source, manga,
"https://api.mangaupdates.com/v1/",
source,
manga,
) {
override val name: String
get() = "MangaUpdates"

View file

@ -18,7 +18,9 @@ import tachiyomi.domain.manga.model.Manga
import tachiyomi.i18n.sy.SYMR
class MyAnimeListPagingSource(manga: Manga, source: CatalogueSource?) : TrackerRecommendationPagingSource(
"https://api.jikan.moe/v4/", source, manga,
"https://api.jikan.moe/v4/",
source,
manga,
) {
override val name: String
get() = "MyAnimeList"

View file

@ -1,3 +1,5 @@
@file:Suppress("PropertyName")
package exh.source
object BlacklistedSources {

View file

@ -1,3 +1,5 @@
@file:Suppress("PropertyName")
package mihon.core.archive
import android.security.keystore.KeyGenParameterSpec

View file

@ -20,8 +20,7 @@ import java.util.concurrent.TimeUnit
import kotlin.math.pow
import kotlin.random.Random
/* SY --> */
open /* SY <-- */ class NetworkHelper(
/* SY --> */ open /* SY <-- */ class NetworkHelper(
private val context: Context,
private val preferences: NetworkPreferences,
// SY -->
@ -29,11 +28,9 @@ open /* SY <-- */ class NetworkHelper(
// SY <--
) {
/* SY --> */
open /* SY <-- */val cookieJar = AndroidCookieJar()
/* SY --> */ open /* SY <-- */val cookieJar = AndroidCookieJar()
/* SY --> */
open /* SY <-- */val client: OkHttpClient =
/* SY --> */ open /* SY <-- */val client: OkHttpClient =
// KMK -->
clientWithTimeOut()

View file

@ -1,3 +1,5 @@
@file:Suppress("PropertyName")
package exh.source
import eu.kanade.tachiyomi.source.Source

View file

@ -2,8 +2,7 @@ package eu.kanade.tachiyomi.source.model
import exh.metadata.metadata.RaisedSearchMetadata
/* SY --> */
open /* SY <-- */ class MangasPage(open val mangas: List<SManga>, open val hasNextPage: Boolean) {
/* SY --> */ open /* SY <-- */ class MangasPage(open val mangas: List<SManga>, open val hasNextPage: Boolean) {
// SY -->
override fun equals(other: Any?): Boolean {
if (this === other) return true

View file

@ -95,8 +95,7 @@ abstract class HttpSource : CatalogueSource {
/**
* Headers used for requests.
*/
/* SY --> */
open /* SY <-- */ val headers: Headers by lazy { headersBuilder().build() }
/* SY --> */ open /* SY <-- */ val headers: Headers by lazy { headersBuilder().build() }
/**
* Default network client for doing requests.

View file

@ -95,10 +95,12 @@ actual class LocalSource(
// Filter out files that are hidden and is not a folder
.filter {
it.isDirectory &&
/* SY --> */ (
// SY -->
(
!it.name.orEmpty().startsWith('.') ||
allowLocalSourceHiddenFolders
) /* SY <-- */
)
// SY <--
}
.distinctBy { it.name }
.filter {