Move to collection literals
This commit is contained in:
1 parent
2163238f48
commit
f07ff61069
19 files changed
+41
-51
No files matched your search
@@ -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<String, Map<String, String>>
|
||||
private val updateLock = Mutex()
|
||||
var initialized by mutableStateOf(false)
|
||||
|
||||
@@ -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),
|
||||
)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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<BaseGalleryInfo>,
|
||||
val galleryInfoList: MutableList<BaseGalleryInfo>,
|
||||
)
|
||||
|
||||
private external fun parseGalleryInfoList(body: ByteBuffer, size: Int = body.limit()): Int
|
||||
@@ -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),
|
||||
)
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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(),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
+2
-2
@@ -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,
|
||||
),
|
||||
)
|
||||
]
|
||||
}
|
||||
+2
-2
@@ -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,
|
||||
),
|
||||
)
|
||||
]
|
||||
}
|
||||
@@ -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,
|
||||
),
|
||||
)
|
||||
]
|
||||
}
|
||||
+2
-2
@@ -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,
|
||||
),
|
||||
)
|
||||
]
|
||||
}
|
||||
+4
-5
@@ -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<Preferences> {
|
||||
internal actual fun getDataStore(name: String?): DataStore<Preferences> {
|
||||
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) },
|
||||
)
|
||||
}
|
||||
@@ -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 []
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -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<Preferences>
|
||||
internal expect fun getDataStore(name: String?): DataStore<Preferences>
|
||||
|
||||
abstract class DataStorePreferences(private val dataStore: DataStore<Preferences>) {
|
||||
constructor(name: String?) : this(getDateStore(name))
|
||||
constructor(name: String?) : this(getDataStore(name))
|
||||
|
||||
val data: Flow<Snapshot>
|
||||
get() = dataStore.data.map { Snapshot(it) }
|
||||
|
||||
Reference in new issue
Block a user