diff --git a/app/src/main/kotlin/com/hippo/ehviewer/client/EhTagDatabase.kt b/app/src/main/kotlin/com/hippo/ehviewer/client/EhTagDatabase.kt index d2857f8b0..a55ec61e7 100644 --- a/app/src/main/kotlin/com/hippo/ehviewer/client/EhTagDatabase.kt +++ b/app/src/main/kotlin/com/hippo/ehviewer/client/EhTagDatabase.kt @@ -53,12 +53,7 @@ import splitties.init.appCtx object EhTagDatabase : CoroutineScope { override val coroutineContext = Dispatchers.IO + Job() private const val NAMESPACE_PREFIX = "n" - private val PREFIXES = arrayOf( - "-", - "~", - "tag:", - "weak:", - ) + private val PREFIXES = ["-", "~", "tag:", "weak:"] private lateinit var tagGroups: Map> private val updateLock = Mutex() var initialized by mutableStateOf(false) diff --git a/app/src/main/kotlin/com/hippo/ehviewer/client/EhUrl.kt b/app/src/main/kotlin/com/hippo/ehviewer/client/EhUrl.kt index 618f9e770..780b06321 100644 --- a/app/src/main/kotlin/com/hippo/ehviewer/client/EhUrl.kt +++ b/app/src/main/kotlin/com/hippo/ehviewer/client/EhUrl.kt @@ -107,14 +107,14 @@ object EhUrl { else -> URL_IMAGE_SEARCH_E } - fun getGalleryDetailUrl(gid: Long, token: String, index: Int = 0, allComment: Boolean = false) = ehUrl(listOf("g", "$gid", token)) { + fun getGalleryDetailUrl(gid: Long, token: String, index: Int = 0, allComment: Boolean = false) = ehUrl(["g", "$gid", token]) { if (index != 0) addQueryParameter("p", "$index") if (allComment) addQueryParameter("hc", "1") }.buildString() - fun getGalleryMultiPageViewerUrl(gid: Long, token: String) = ehUrl(listOf("mpv", "$gid", token)).buildString() + fun getGalleryMultiPageViewerUrl(gid: Long, token: String) = ehUrl(["mpv", "$gid", token]).buildString() - fun getPageUrl(gid: Long, index: Int, pToken: String, nl: String? = null) = ehUrl(listOf("s", pToken, "$gid-${index + 1}")) { + fun getPageUrl(gid: Long, index: Int, pToken: String, nl: String? = null) = ehUrl(["s", pToken, "$gid-${index + 1}"]) { addQueryParameterIfNotBlank("nl", nl) }.buildString() @@ -143,7 +143,7 @@ object EhUrl { } inline fun ehUrl(path: String? = null, host: String = EhUrl.domain, builder: ParametersBuilder.() -> Unit) = ehUrl( - path = if (path.isNullOrBlank()) emptyList() else listOf(path), + path = if (path.isNullOrBlank()) [] else [path], host = host, parameters = Parameters.build(builder), ) 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 b07cd4716..b20be465d 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 @@ -208,7 +208,7 @@ data class ListUrlBuilder( }.buildString() MODE_UPLOADER, MODE_TAG -> { val path = if (mode == MODE_UPLOADER) "uploader" else "tag" - ehUrl(listOf(path, requireNotNull(keyword))) { + ehUrl([path, requireNotNull(keyword)]) { addQueryParameterIfNotBlank("prev", prev) addQueryParameterIfNotBlank("next", next) addQueryParameterIfNotBlank("seek", jumpTo) diff --git a/app/src/main/kotlin/com/hippo/ehviewer/client/parser/GalleryListParser.kt b/app/src/main/kotlin/com/hippo/ehviewer/client/parser/GalleryListParser.kt index f55e5383f..414a7e682 100644 --- a/app/src/main/kotlin/com/hippo/ehviewer/client/parser/GalleryListParser.kt +++ b/app/src/main/kotlin/com/hippo/ehviewer/client/parser/GalleryListParser.kt @@ -13,14 +13,14 @@ object GalleryListParser { throw ParseException("Can't parse gallery list", it) } - val emptyResult = GalleryListResult(null, null, arrayListOf()) + val emptyResult = GalleryListResult(null, null, []) } @Serializable data class GalleryListResult( val prev: String?, val next: String?, - val galleryInfoList: ArrayList, + val galleryInfoList: MutableList, ) private external fun parseGalleryInfoList(body: ByteBuffer, size: Int = body.limit()): Int diff --git a/app/src/main/kotlin/com/hippo/ehviewer/download/SortMode.kt b/app/src/main/kotlin/com/hippo/ehviewer/download/SortMode.kt index dd2185359..4ba2e4cc4 100644 --- a/app/src/main/kotlin/com/hippo/ehviewer/download/SortMode.kt +++ b/app/src/main/kotlin/com/hippo/ehviewer/download/SortMode.kt @@ -48,7 +48,7 @@ data class SortMode(val field: Field, val order: Order, val groupByDownloadLabel return SortMode(field, order, groupByDownloadLabel) } val Default = SortMode(Field.TIME, Order.DESC) - val All = listOf( + val All = [ Default, SortMode(Field.TIME, Order.ASC), SortMode(Field.GID, Order.DESC), @@ -57,6 +57,6 @@ data class SortMode(val field: Field, val order: Order, val groupByDownloadLabel SortMode(Field.TITLE, Order.DESC), SortMode(Field.PAGES, Order.ASC), SortMode(Field.PAGES, Order.DESC), - ) + ] } } 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 d61a2bab5..f088fafba 100644 --- a/app/src/main/kotlin/com/hippo/ehviewer/spider/SpiderDen.kt +++ b/app/src/main/kotlin/com/hippo/ehviewer/spider/SpiderDen.kt @@ -334,7 +334,7 @@ class SpiderDen(val info: GalleryInfo) { downloadDir?.run { resolve(COMIC_INFO_FILE).also { if (info !is GalleryDetail && fetchMetadata) { - EhEngine.fillGalleryListByApi(listOf(info)) + EhEngine.fillGalleryListByApi([info]) } info.getComicInfo().apply { writeComicInfo(this, it) 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 64d408c90..f0b28cce8 100644 --- a/app/src/main/kotlin/com/hippo/ehviewer/ui/CommonOperations.kt +++ b/app/src/main/kotlin/com/hippo/ehviewer/ui/CommonOperations.kt @@ -394,7 +394,7 @@ suspend fun showMoveDownloadLabel(info: GalleryInfo) { val selected = awaitSelectItem(labels, R.string.download_move_dialog_title) val downloadInfo = DownloadManager.getDownloadInfo(info.gid) ?: return val label = if (selected == 0) null else labels[selected] - DownloadManager.changeLabel(listOf(downloadInfo), label) + DownloadManager.changeLabel([downloadInfo], label) } context(_: DialogState) diff --git a/app/src/main/kotlin/com/hippo/ehviewer/ui/main/SearchFilter.kt b/app/src/main/kotlin/com/hippo/ehviewer/ui/main/SearchFilter.kt index 829f44bd0..2c60acbd7 100644 --- a/app/src/main/kotlin/com/hippo/ehviewer/ui/main/SearchFilter.kt +++ b/app/src/main/kotlin/com/hippo/ehviewer/ui/main/SearchFilter.kt @@ -47,7 +47,7 @@ import com.hippo.ehviewer.ui.tools.DialogState import com.hippo.ehviewer.ui.tools.awaitResult import kotlinx.coroutines.CoroutineScope -private val categoryTable = arrayOf( +private val categoryTable = [ EhUtils.DOUJINSHI to R.string.doujinshi, EhUtils.MANGA to R.string.manga, EhUtils.ARTIST_CG to R.string.artist_cg, @@ -58,7 +58,7 @@ private val categoryTable = arrayOf( EhUtils.COSPLAY to R.string.cosplay, EhUtils.ASIAN_PORN to R.string.asian_porn, EhUtils.MISC to R.string.misc, -) +] @Composable context(_: DialogState, _: CoroutineScope, _: Context) diff --git a/app/src/main/kotlin/com/hippo/ehviewer/ui/reader/ColorFilterSetting.kt b/app/src/main/kotlin/com/hippo/ehviewer/ui/reader/ColorFilterSetting.kt index 0bee9859b..9f3748086 100644 --- a/app/src/main/kotlin/com/hippo/ehviewer/ui/reader/ColorFilterSetting.kt +++ b/app/src/main/kotlin/com/hippo/ehviewer/ui/reader/ColorFilterSetting.kt @@ -88,7 +88,7 @@ fun ColorFilterSetting() = Column(modifier = Modifier.verticalScroll(rememberScr SpinnerChoice( title = stringResource(id = R.string.pref_color_filter_mode), entries = stringArrayResource(id = com.hippo.ehviewer.R.array.color_filter_modes), - values = listOf(0, 1, 2, 3, 4, 5), + values = [0, 1, 2, 3, 4, 5], field = Settings.colorFilterMode.asMutableState(), ) SwitchChoice( diff --git a/app/src/main/kotlin/com/hippo/ehviewer/ui/reader/ReaderModeSetting.kt b/app/src/main/kotlin/com/hippo/ehviewer/ui/reader/ReaderModeSetting.kt index 3b50cac68..a8dca5c63 100644 --- a/app/src/main/kotlin/com/hippo/ehviewer/ui/reader/ReaderModeSetting.kt +++ b/app/src/main/kotlin/com/hippo/ehviewer/ui/reader/ReaderModeSetting.kt @@ -58,7 +58,7 @@ private fun PagerSetting() = Column { SpinnerChoice( title = stringResource(id = R.string.pref_viewer_nav), entries = stringArrayResource(id = com.hippo.ehviewer.R.array.pager_nav), - values = listOf(0, 1, 2, 3, 4, 5), + values = [0, 1, 2, 3, 4, 5], field = pagerNav, ) AnimatedVisibility(visible = pagerNav.value != 5) { @@ -66,7 +66,7 @@ private fun PagerSetting() = Column { SpinnerChoice( title = stringResource(id = R.string.pref_read_with_tapping_inverted), entries = stringArrayResource(id = com.hippo.ehviewer.R.array.invert_tapping_mode), - values = listOf(0, 1, 2, 3), + values = [0, 1, 2, 3], field = Settings.readerPagerNavInverted.asMutableState(), ) SwitchChoice( @@ -79,7 +79,7 @@ private fun PagerSetting() = Column { SpinnerChoice( title = stringResource(id = R.string.pref_image_scale_type), entries = stringArrayResource(id = com.hippo.ehviewer.R.array.image_scale_type), - values = listOf(1, 2, 3, 4, 5, 6), + values = [1, 2, 3, 4, 5, 6], field = scaleType, ) AnimatedVisibility(visible = scaleType.value == 1) { @@ -91,7 +91,7 @@ private fun PagerSetting() = Column { SpinnerChoice( title = stringResource(id = R.string.pref_zoom_start), entries = stringArrayResource(id = com.hippo.ehviewer.R.array.zoom_start), - values = listOf(1, 2, 3, 4), + values = [1, 2, 3, 4], field = Settings.zoomStart.asMutableState(), ) SwitchChoice( @@ -111,14 +111,14 @@ private fun WebtoonSetting() = Column { SpinnerChoice( title = stringResource(id = R.string.pref_viewer_nav), entries = stringArrayResource(id = com.hippo.ehviewer.R.array.webtoon_nav), - values = listOf(0, 1, 2, 3, 4, 5), + values = [0, 1, 2, 3, 4, 5], field = webtoonNav, ) AnimatedVisibility(visible = webtoonNav.value != 5) { SpinnerChoice( title = stringResource(id = R.string.pref_read_with_tapping_inverted), entries = stringArrayResource(id = com.hippo.ehviewer.R.array.invert_tapping_mode), - values = listOf(0, 1, 2, 3), + values = [0, 1, 2, 3], field = Settings.readerWebtoonNavInverted.asMutableState(), ) } diff --git a/app/src/main/kotlin/com/hippo/ehviewer/ui/screen/GalleryListScreen.kt b/app/src/main/kotlin/com/hippo/ehviewer/ui/screen/GalleryListScreen.kt index d3bbee83b..20598d225 100644 --- a/app/src/main/kotlin/com/hippo/ehviewer/ui/screen/GalleryListScreen.kt +++ b/app/src/main/kotlin/com/hippo/ehviewer/ui/screen/GalleryListScreen.kt @@ -482,9 +482,9 @@ fun AnimatedVisibilityScope.GalleryListScreen( searchFieldState = searchFieldState, suggestionProvider = { GalleryDetailUrlParser.parse(it, false)?.run { - listOf(GalleryDetailUrlSuggestion(gid, token)) + [GalleryDetailUrlSuggestion(gid, token)] } ?: GalleryPageUrlParser.parse(it, false)?.run { - listOf(GalleryPageUrlSuggestion(gid, pToken, page)) + [GalleryPageUrlSuggestion(gid, pToken, page)] }.orEmpty() }, localSearch = false, @@ -580,7 +580,7 @@ fun AnimatedVisibilityScope.GalleryListScreen( onExpandChanged = { fabExpanded = it }, autoCancel = true, ) { - if (urlBuilder.mode in arrayOf(MODE_NORMAL, MODE_UPLOADER, MODE_TAG)) { + if (urlBuilder.mode in [MODE_NORMAL, MODE_UPLOADER, MODE_TAG]) { onClick(Icons.Default.Shuffle) { urlBuilder.setRange(Random.nextInt(100)) data.refresh() diff --git a/app/src/main/kotlin/com/hippo/ehviewer/ui/tools/BBCodeTextContextMenu.kt b/app/src/main/kotlin/com/hippo/ehviewer/ui/tools/BBCodeTextContextMenu.kt index da4df909e..173a8f317 100644 --- a/app/src/main/kotlin/com/hippo/ehviewer/ui/tools/BBCodeTextContextMenu.kt +++ b/app/src/main/kotlin/com/hippo/ehviewer/ui/tools/BBCodeTextContextMenu.kt @@ -94,7 +94,7 @@ fun AnnotatedString.normalizeSpan(): AnnotatedString { val italic = filterMerged(SpanStyle(fontStyle = FontStyle.Italic)) { it.fontStyle == FontStyle.Italic } val underline = filterMerged(SpanStyle(textDecoration = TextDecoration.Underline)) { it.textDecoration == TextDecoration.Underline } val linethrough = filterMerged(SpanStyle(textDecoration = TextDecoration.LineThrough)) { it.textDecoration == TextDecoration.LineThrough } - listOf(bold, italic, underline, linethrough).flatten() + bold + italic + underline + linethrough } return AnnotatedString(text, spans) } diff --git a/app/src/main/kotlin/eu/kanade/tachiyomi/ui/reader/viewer/navigation/EdgeNavigation.kt b/app/src/main/kotlin/eu/kanade/tachiyomi/ui/reader/viewer/navigation/EdgeNavigation.kt index 62b4f0f0e..8e585e084 100644 --- a/app/src/main/kotlin/eu/kanade/tachiyomi/ui/reader/viewer/navigation/EdgeNavigation.kt +++ b/app/src/main/kotlin/eu/kanade/tachiyomi/ui/reader/viewer/navigation/EdgeNavigation.kt @@ -14,7 +14,7 @@ import eu.kanade.tachiyomi.ui.reader.viewer.ViewerNavigation * +---+---+---+ */ object EdgeNavigation : ViewerNavigation() { - override val originalRegions = listOf( + override val originalRegions = [ Region( rect = Rect(0f, 0f, 0.33f, 1f), type = NavigationRegion.NEXT, @@ -27,5 +27,5 @@ object EdgeNavigation : ViewerNavigation() { rect = Rect(0.66f, 0f, 1f, 1f), type = NavigationRegion.NEXT, ), - ) + ] } diff --git a/app/src/main/kotlin/eu/kanade/tachiyomi/ui/reader/viewer/navigation/KindlishNavigation.kt b/app/src/main/kotlin/eu/kanade/tachiyomi/ui/reader/viewer/navigation/KindlishNavigation.kt index ae9b98d1b..21085e747 100644 --- a/app/src/main/kotlin/eu/kanade/tachiyomi/ui/reader/viewer/navigation/KindlishNavigation.kt +++ b/app/src/main/kotlin/eu/kanade/tachiyomi/ui/reader/viewer/navigation/KindlishNavigation.kt @@ -14,7 +14,7 @@ import eu.kanade.tachiyomi.ui.reader.viewer.ViewerNavigation * +---+---+---+ */ object KindlishNavigation : ViewerNavigation() { - override val originalRegions = listOf( + override val originalRegions = [ Region( rect = Rect(0.33f, 0.33f, 1f, 1f), type = NavigationRegion.NEXT, @@ -23,5 +23,5 @@ object KindlishNavigation : ViewerNavigation() { rect = Rect(0f, 0.33f, 0.33f, 1f), type = NavigationRegion.PREV, ), - ) + ] } diff --git a/app/src/main/kotlin/eu/kanade/tachiyomi/ui/reader/viewer/navigation/LNavigation.kt b/app/src/main/kotlin/eu/kanade/tachiyomi/ui/reader/viewer/navigation/LNavigation.kt index 8d9959f46..1b8ba3bbc 100644 --- a/app/src/main/kotlin/eu/kanade/tachiyomi/ui/reader/viewer/navigation/LNavigation.kt +++ b/app/src/main/kotlin/eu/kanade/tachiyomi/ui/reader/viewer/navigation/LNavigation.kt @@ -14,7 +14,7 @@ import eu.kanade.tachiyomi.ui.reader.viewer.ViewerNavigation * +---+---+---+ */ object LNavigation : ViewerNavigation() { - override val originalRegions = listOf( + override val originalRegions = [ Region( rect = Rect(0f, 0.33f, 0.33f, 0.66f), type = NavigationRegion.PREV, @@ -31,5 +31,5 @@ object LNavigation : ViewerNavigation() { rect = Rect(0f, 0.66f, 1f, 1f), type = NavigationRegion.NEXT, ), - ) + ] } diff --git a/app/src/main/kotlin/eu/kanade/tachiyomi/ui/reader/viewer/navigation/RightAndLeftNavigation.kt b/app/src/main/kotlin/eu/kanade/tachiyomi/ui/reader/viewer/navigation/RightAndLeftNavigation.kt index 7e9643a67..e4e2010bf 100644 --- a/app/src/main/kotlin/eu/kanade/tachiyomi/ui/reader/viewer/navigation/RightAndLeftNavigation.kt +++ b/app/src/main/kotlin/eu/kanade/tachiyomi/ui/reader/viewer/navigation/RightAndLeftNavigation.kt @@ -14,7 +14,7 @@ import eu.kanade.tachiyomi.ui.reader.viewer.ViewerNavigation * +---+---+---+ */ object RightAndLeftNavigation : ViewerNavigation() { - override val originalRegions = listOf( + override val originalRegions = [ Region( rect = Rect(0f, 0f, 0.33f, 1f), type = NavigationRegion.LEFT, @@ -23,5 +23,5 @@ object RightAndLeftNavigation : ViewerNavigation() { rect = Rect(0.66f, 0f, 1f, 1f), type = NavigationRegion.RIGHT, ), - ) + ] } diff --git a/core/data/src/androidMain/kotlin/com/ehviewer/core/preferences/DataStorePreferences.android.kt b/core/data/src/androidMain/kotlin/com/ehviewer/core/preferences/DataStorePreferences.android.kt index f145e3d43..e3799c578 100644 --- a/core/data/src/androidMain/kotlin/com/ehviewer/core/preferences/DataStorePreferences.android.kt +++ b/core/data/src/androidMain/kotlin/com/ehviewer/core/preferences/DataStorePreferences.android.kt @@ -7,12 +7,11 @@ import androidx.datastore.preferences.core.Preferences import androidx.datastore.preferences.preferencesDataStoreFile import splitties.init.appCtx -internal actual fun getDateStore(name: String?): DataStore { +internal actual fun getDataStore(name: String?): DataStore { val context = appCtx val actualName = name ?: "${context.packageName}_preferences" return PreferenceDataStoreFactory.create( - migrations = listOf(SharedPreferencesMigration(context = context, sharedPreferencesName = actualName)), - ) { - context.preferencesDataStoreFile(actualName) - } + migrations = [SharedPreferencesMigration(context = context, sharedPreferencesName = actualName)], + produceFile = { context.preferencesDataStoreFile(actualName) }, + ) } diff --git a/core/data/src/commonMain/kotlin/com/ehviewer/core/network/EhCookieStore.kt b/core/data/src/commonMain/kotlin/com/ehviewer/core/network/EhCookieStore.kt index e1851a0da..938dd741e 100644 --- a/core/data/src/commonMain/kotlin/com/ehviewer/core/network/EhCookieStore.kt +++ b/core/data/src/commonMain/kotlin/com/ehviewer/core/network/EhCookieStore.kt @@ -46,11 +46,7 @@ object EhCookieStore : CookiesStorage { val ipbMemberId = eCookies?.get(KEY_IPB_MEMBER_ID) val ipbPassHash = eCookies?.get(KEY_IPB_PASS_HASH) val igneous = exCookies?.get(KEY_IGNEOUS) - return listOf( - KEY_IPB_MEMBER_ID to ipbMemberId, - KEY_IPB_PASS_HASH to ipbPassHash, - KEY_IGNEOUS to igneous, - ) + return [KEY_IPB_MEMBER_ID to ipbMemberId, KEY_IPB_PASS_HASH to ipbPassHash, KEY_IGNEOUS to igneous] } fun isCloudflareBypassed() = manager.getCookies(urlE)?.containsKey("cf_clearance") == true @@ -74,6 +70,6 @@ object EhCookieStore : CookiesStorage { if (checkTips) { add(sTipsCookie) } - } ?: if (checkTips) listOf(sTipsCookie) else emptyList() + } ?: if (checkTips) [sTipsCookie] else [] } } diff --git a/core/data/src/commonMain/kotlin/com/ehviewer/core/preferences/DataStorePreferences.kt b/core/data/src/commonMain/kotlin/com/ehviewer/core/preferences/DataStorePreferences.kt index ed3182813..4ea8b6686 100644 --- a/core/data/src/commonMain/kotlin/com/ehviewer/core/preferences/DataStorePreferences.kt +++ b/core/data/src/commonMain/kotlin/com/ehviewer/core/preferences/DataStorePreferences.kt @@ -15,10 +15,10 @@ import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.first import kotlinx.coroutines.flow.map -internal expect fun getDateStore(name: String?): DataStore +internal expect fun getDataStore(name: String?): DataStore abstract class DataStorePreferences(private val dataStore: DataStore) { - constructor(name: String?) : this(getDateStore(name)) + constructor(name: String?) : this(getDataStore(name)) val data: Flow get() = dataStore.data.map { Snapshot(it) }