Drop kotlinx-collections-immutable usage (#3380)

This commit is contained in:
AntsyLich
2026-06-04 02:45:24 +06:00
committed by GitHub
parent 7f8851de6a
commit cd27b10750
91 changed files with 317 additions and 523 deletions
-1
View File
@@ -199,7 +199,6 @@ dependencies {
implementation(libs.androidx.sqlite.bundled)
implementation(libs.kotlin.reflect)
implementation(libs.kotlinx.collections.immutable)
implementation(libs.bundles.kotlinx.coroutines)
@@ -22,7 +22,6 @@ import eu.kanade.presentation.browse.components.BrowseSourceList
import eu.kanade.presentation.components.AppBar
import eu.kanade.presentation.util.formattedMessage
import eu.kanade.tachiyomi.source.Source
import kotlinx.collections.immutable.persistentListOf
import kotlinx.coroutines.flow.StateFlow
import tachiyomi.core.common.i18n.stringResource
import tachiyomi.domain.library.model.LibraryDisplayMode
@@ -86,7 +85,7 @@ fun BrowseSourceContent(
else -> stringResource(MR.strings.no_results_found)
},
actions = if (source is LocalSource) {
persistentListOf(
listOf(
EmptyScreenAction(
stringRes = MR.strings.local_source_help_guide,
icon = Icons.AutoMirrored.Outlined.HelpOutline,
@@ -94,7 +93,7 @@ fun BrowseSourceContent(
),
)
} else {
persistentListOf(
listOf(
EmptyScreenAction(
stringRes = MR.strings.action_retry,
icon = Icons.Outlined.Refresh,
@@ -56,8 +56,6 @@ import eu.kanade.tachiyomi.source.ConfigurableSource
import eu.kanade.tachiyomi.ui.browse.extension.details.ExtensionDetailsScreenModel
import eu.kanade.tachiyomi.util.system.LocaleHelper
import eu.kanade.tachiyomi.util.system.copyToClipboard
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.persistentListOf
import tachiyomi.i18n.MR
import tachiyomi.presentation.core.components.ScrollbarLazyColumn
import tachiyomi.presentation.core.components.material.Scaffold
@@ -95,37 +93,35 @@ fun ExtensionDetailsScreen(
navigateUp = navigateUp,
actions = {
AppBarActions(
actions = persistentListOf<AppBar.AppBarAction>().builder()
.apply {
if (url != null) {
add(
AppBar.Action(
title = stringResource(MR.strings.action_open_repo),
icon = Icons.AutoMirrored.Outlined.Launch,
onClick = {
uriHandler.openUri(url)
},
),
)
}
addAll(
listOf(
AppBar.OverflowAction(
title = stringResource(MR.strings.action_enable_all),
onClick = onClickEnableAll,
),
AppBar.OverflowAction(
title = stringResource(MR.strings.action_disable_all),
onClick = onClickDisableAll,
),
AppBar.OverflowAction(
title = stringResource(MR.strings.pref_clear_cookies),
onClick = onClickClearCookies,
),
actions = buildList {
if (url != null) {
add(
AppBar.Action(
title = stringResource(MR.strings.action_open_repo),
icon = Icons.AutoMirrored.Outlined.Launch,
onClick = {
uriHandler.openUri(url)
},
),
)
}
.build(),
addAll(
listOf(
AppBar.OverflowAction(
title = stringResource(MR.strings.action_enable_all),
onClick = onClickEnableAll,
),
AppBar.OverflowAction(
title = stringResource(MR.strings.action_disable_all),
onClick = onClickDisableAll,
),
AppBar.OverflowAction(
title = stringResource(MR.strings.pref_clear_cookies),
onClick = onClickClearCookies,
),
),
)
},
)
},
scrollBehavior = scrollBehavior,
@@ -157,7 +153,7 @@ fun ExtensionDetailsScreen(
private fun ExtensionDetails(
contentPadding: PaddingValues,
extension: Extension.Installed,
sources: ImmutableList<ExtensionSourceItem>,
sources: List<ExtensionSourceItem>,
incognitoMode: Boolean,
onClickSourcePreferences: (sourceId: Long) -> Unit,
onClickUninstall: () -> Unit,
@@ -56,7 +56,6 @@ import eu.kanade.tachiyomi.ui.browse.extension.ExtensionUiModel
import eu.kanade.tachiyomi.ui.browse.extension.ExtensionsScreenModel
import eu.kanade.tachiyomi.util.system.LocaleHelper
import eu.kanade.tachiyomi.util.system.launchRequestPackageInstallsPermission
import kotlinx.collections.immutable.persistentListOf
import tachiyomi.i18n.MR
import tachiyomi.presentation.core.components.FastScrollLazyColumn
import tachiyomi.presentation.core.components.material.PullRefresh
@@ -104,7 +103,7 @@ fun ExtensionScreen(
EmptyScreen(
stringRes = msg,
modifier = Modifier.padding(contentPadding),
actions = persistentListOf(
actions = listOf(
EmptyScreenAction(
stringRes = MR.strings.extensionStores,
icon = Icons.Outlined.Settings,
@@ -26,7 +26,6 @@ import eu.kanade.presentation.browse.components.BaseSourceItem
import eu.kanade.presentation.browse.components.SourceIcon
import eu.kanade.tachiyomi.ui.browse.migration.sources.MigrateSourceScreenModel
import eu.kanade.tachiyomi.util.system.copyToClipboard
import kotlinx.collections.immutable.ImmutableList
import tachiyomi.domain.source.model.Source
import tachiyomi.i18n.MR
import tachiyomi.presentation.core.components.Badge
@@ -76,7 +75,7 @@ fun MigrateSourceScreen(
@Composable
private fun MigrateSourceList(
list: ImmutableList<Pair<Source, Long>>,
list: List<Pair<Source, Long>>,
contentPadding: PaddingValues,
onClickItem: (Source) -> Unit,
onLongClickItem: (Source) -> Unit,
@@ -18,7 +18,6 @@ import eu.kanade.presentation.components.RadioMenuItem
import eu.kanade.presentation.components.SearchToolbar
import eu.kanade.tachiyomi.source.ConfigurableSource
import eu.kanade.tachiyomi.source.Source
import kotlinx.collections.immutable.persistentListOf
import tachiyomi.domain.library.model.LibraryDisplayMode
import tachiyomi.i18n.MR
import tachiyomi.presentation.core.i18n.stringResource
@@ -54,44 +53,42 @@ fun BrowseSourceToolbar(
onClickCloseSearch = navigateUp,
actions = {
AppBarActions(
actions = persistentListOf<AppBar.AppBarAction>().builder()
.apply {
actions = buildList {
add(
AppBar.Action(
title = stringResource(MR.strings.action_display_mode),
icon = if (displayMode == LibraryDisplayMode.List) {
Icons.AutoMirrored.Filled.ViewList
} else {
Icons.Filled.ViewModule
},
onClick = { selectingDisplayMode = true },
),
)
if (isLocalSource) {
add(
AppBar.Action(
title = stringResource(MR.strings.action_display_mode),
icon = if (displayMode == LibraryDisplayMode.List) {
Icons.AutoMirrored.Filled.ViewList
} else {
Icons.Filled.ViewModule
},
onClick = { selectingDisplayMode = true },
AppBar.OverflowAction(
title = stringResource(MR.strings.label_help),
onClick = onHelpClick,
),
)
} else {
add(
AppBar.OverflowAction(
title = stringResource(MR.strings.action_open_in_web_view),
onClick = onWebViewClick,
),
)
if (isLocalSource) {
add(
AppBar.OverflowAction(
title = stringResource(MR.strings.label_help),
onClick = onHelpClick,
),
)
} else {
add(
AppBar.OverflowAction(
title = stringResource(MR.strings.action_open_in_web_view),
onClick = onWebViewClick,
),
)
}
if (isConfigurableSource) {
add(
AppBar.OverflowAction(
title = stringResource(MR.strings.action_settings),
onClick = onSettingsClick,
),
)
}
}
.build(),
if (isConfigurableSource) {
add(
AppBar.OverflowAction(
title = stringResource(MR.strings.action_settings),
onClick = onSettingsClick,
),
)
}
},
)
DropdownMenu(
@@ -27,8 +27,6 @@ import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
import eu.kanade.core.preference.asToggleableState
import eu.kanade.presentation.category.visualName
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.toImmutableList
import kotlinx.coroutines.delay
import tachiyomi.core.common.preference.CheckboxState
import tachiyomi.domain.category.model.Category
@@ -41,7 +39,7 @@ import kotlin.time.Duration.Companion.seconds
fun CategoryCreateDialog(
onDismissRequest: () -> Unit,
onCreate: (String) -> Unit,
categories: ImmutableList<String>,
categories: List<String>,
) {
var name by remember { mutableStateOf("") }
@@ -103,7 +101,7 @@ fun CategoryCreateDialog(
fun CategoryRenameDialog(
onDismissRequest: () -> Unit,
onRename: (String) -> Unit,
categories: ImmutableList<String>,
categories: List<String>,
category: String,
) {
var name by remember { mutableStateOf(category) }
@@ -195,7 +193,7 @@ fun CategoryDeleteDialog(
@Composable
fun ChangeCategoryDialog(
initialSelection: ImmutableList<CheckboxState<Category>>,
initialSelection: List<CheckboxState<Category>>,
onDismissRequest: () -> Unit,
onEditCategories: () -> Unit,
onConfirm: (List<Long>, List<Long>) -> Unit,
@@ -267,7 +265,7 @@ fun ChangeCategoryDialog(
if (index != -1) {
val mutableList = selection.toMutableList()
mutableList[index] = it.next()
selection = mutableList.toList().toImmutableList()
selection = mutableList.toList()
}
}
Row(
@@ -51,7 +51,6 @@ import androidx.compose.ui.text.input.VisualTransformation
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import kotlinx.collections.immutable.ImmutableList
import tachiyomi.i18n.MR
import tachiyomi.presentation.core.i18n.stringResource
import tachiyomi.presentation.core.util.clearFocusOnSoftKeyboardHide
@@ -190,7 +189,7 @@ fun AppBarTitle(
@Composable
fun AppBarActions(
actions: ImmutableList<AppBar.AppBarAction>,
actions: List<AppBar.AppBarAction>,
) {
var showMenu by remember { mutableStateOf(false) }
@@ -6,7 +6,6 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.DpOffset
import eu.kanade.presentation.manga.DownloadAction
import kotlinx.collections.immutable.persistentListOf
import tachiyomi.i18n.MR
import tachiyomi.presentation.core.i18n.pluralStringResource
import tachiyomi.presentation.core.i18n.stringResource
@@ -52,7 +51,7 @@ private fun DownloadDropdownMenuItems(
onDismissRequest: () -> Unit,
onDownloadClicked: (DownloadAction) -> Unit,
) {
val options = persistentListOf(
val options = listOf(
DownloadAction.NEXT_1_CHAPTER to pluralStringResource(MR.plurals.download_amount, 1, 1),
DownloadAction.NEXT_5_CHAPTERS to pluralStringResource(MR.plurals.download_amount, 5, 5),
DownloadAction.NEXT_10_CHAPTERS to pluralStringResource(MR.plurals.download_amount, 10, 10),
@@ -7,7 +7,6 @@ import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
import androidx.compose.ui.tooling.preview.PreviewLightDark
import eu.kanade.presentation.theme.TachiyomiPreviewTheme
import kotlinx.collections.immutable.persistentListOf
import tachiyomi.i18n.MR
import tachiyomi.presentation.core.screens.EmptyScreen
import tachiyomi.presentation.core.screens.EmptyScreenAction
@@ -31,7 +30,7 @@ private fun WithActionPreview() {
Surface {
EmptyScreen(
stringRes = MR.strings.empty_screen,
actions = persistentListOf(
actions = listOf(
EmptyScreenAction(
stringRes = MR.strings.action_retry,
icon = Icons.Outlined.Refresh,
@@ -27,7 +27,6 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.compose.ui.util.fastForEachIndexed
import kotlinx.collections.immutable.ImmutableList
import kotlinx.coroutines.launch
import tachiyomi.i18n.MR
import tachiyomi.presentation.core.components.material.TabText
@@ -41,7 +40,7 @@ object TabbedDialogPaddings {
@Composable
fun TabbedDialog(
onDismissRequest: () -> Unit,
tabTitles: ImmutableList<String>,
tabTitles: List<String>,
modifier: Modifier = Modifier,
tabOverflowMenuContent: (@Composable ColumnScope.(() -> Unit) -> Unit)? = null,
pagerState: PagerState = rememberPagerState { tabTitles.size },
@@ -22,8 +22,6 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.zIndex
import dev.icerock.moko.resources.StringResource
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.persistentListOf
import kotlinx.coroutines.launch
import tachiyomi.presentation.core.components.material.Scaffold
import tachiyomi.presentation.core.components.material.TabText
@@ -32,7 +30,7 @@ import tachiyomi.presentation.core.i18n.stringResource
@Composable
fun TabbedScreen(
titleRes: StringResource,
tabs: ImmutableList<TabContent>,
tabs: List<TabContent>,
state: PagerState = rememberPagerState { tabs.size },
searchQuery: String? = null,
onChangeSearchQuery: (String?) -> Unit = {},
@@ -94,6 +92,6 @@ data class TabContent(
val titleRes: StringResource,
val badgeNumber: Int? = null,
val searchEnabled: Boolean = false,
val actions: ImmutableList<AppBar.AppBarAction> = persistentListOf(),
val actions: List<AppBar.AppBarAction> = listOf(),
val content: @Composable (contentPadding: PaddingValues, snackbarHostState: SnackbarHostState) -> Unit,
)
@@ -20,7 +20,6 @@ import eu.kanade.presentation.history.components.HistoryItem
import eu.kanade.presentation.theme.TachiyomiPreviewTheme
import eu.kanade.presentation.util.animateItemFastScroll
import eu.kanade.tachiyomi.ui.history.HistoryScreenModel
import kotlinx.collections.immutable.persistentListOf
import tachiyomi.domain.history.model.HistoryWithRelations
import tachiyomi.i18n.MR
import tachiyomi.presentation.core.components.FastScrollLazyColumn
@@ -49,7 +48,7 @@ fun HistoryScreen(
onChangeSearchQuery = onSearchQueryChange,
actions = {
AppBarActions(
persistentListOf(
listOf(
AppBar.Action(
title = stringResource(MR.strings.pref_clear_history),
icon = Icons.Outlined.DeleteSweep,
@@ -21,7 +21,6 @@ import eu.kanade.presentation.components.TabbedDialog
import eu.kanade.presentation.components.TabbedDialogPaddings
import eu.kanade.tachiyomi.ui.library.LibrarySettingsScreenModel
import eu.kanade.tachiyomi.util.system.isReleaseBuildType
import kotlinx.collections.immutable.persistentListOf
import tachiyomi.core.common.preference.TriState
import tachiyomi.domain.category.model.Category
import tachiyomi.domain.library.model.LibraryDisplayMode
@@ -47,7 +46,7 @@ fun LibrarySettingsDialog(
) {
TabbedDialog(
onDismissRequest = onDismissRequest,
tabTitles = persistentListOf(
tabTitles = listOf(
stringResource(MR.strings.action_filter),
stringResource(MR.strings.action_sort),
stringResource(MR.strings.action_display),
@@ -19,7 +19,6 @@ import androidx.compose.ui.unit.sp
import eu.kanade.presentation.components.AppBar
import eu.kanade.presentation.components.AppBarActions
import eu.kanade.presentation.components.SearchToolbar
import kotlinx.collections.immutable.persistentListOf
import tachiyomi.i18n.MR
import tachiyomi.presentation.core.components.Pill
import tachiyomi.presentation.core.i18n.stringResource
@@ -96,7 +95,7 @@ private fun LibraryRegularToolbar(
actions = {
val filterTint = if (hasFilters) MaterialTheme.colorScheme.active else LocalContentColor.current
AppBarActions(
persistentListOf(
listOf(
AppBar.Action(
title = stringResource(MR.strings.action_filter),
icon = Icons.Outlined.FilterList,
@@ -133,7 +132,7 @@ private fun LibrarySelectionToolbar(
titleContent = { Text(text = "$selectedCount") },
actions = {
AppBarActions(
persistentListOf(
listOf(
AppBar.Action(
title = stringResource(MR.strings.action_select_all),
icon = Icons.Outlined.SelectAll,
@@ -31,7 +31,6 @@ import eu.kanade.domain.base.BasePreferences
import eu.kanade.domain.manga.model.downloadedFilter
import eu.kanade.presentation.components.TabbedDialog
import eu.kanade.presentation.components.TabbedDialogPaddings
import kotlinx.collections.immutable.persistentListOf
import tachiyomi.core.common.preference.TriState
import tachiyomi.domain.manga.model.Manga
import tachiyomi.i18n.MR
@@ -70,7 +69,7 @@ fun ChapterSettingsDialog(
TabbedDialog(
onDismissRequest = onDismissRequest,
tabTitles = persistentListOf(
tabTitles = listOf(
stringResource(MR.strings.action_filter),
stringResource(MR.strings.action_sort),
stringResource(MR.strings.action_display),
@@ -48,7 +48,6 @@ import eu.kanade.presentation.components.AppBarActions
import eu.kanade.presentation.components.DropdownMenu
import eu.kanade.presentation.manga.EditCoverAction
import eu.kanade.tachiyomi.ui.reader.viewer.ReaderPageImageView
import kotlinx.collections.immutable.persistentListOf
import tachiyomi.domain.manga.model.Manga
import tachiyomi.i18n.MR
import tachiyomi.presentation.core.components.material.Scaffold
@@ -93,7 +92,7 @@ fun MangaCoverDialog(
Spacer(modifier = Modifier.weight(1f))
ActionsPill {
AppBarActions(
actions = persistentListOf(
actions = listOf(
AppBar.Action(
title = stringResource(MR.strings.action_share),
icon = Icons.Outlined.Share,
@@ -20,7 +20,6 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.DpSize
import androidx.compose.ui.unit.dp
import eu.kanade.tachiyomi.util.system.isReleaseBuildType
import kotlinx.collections.immutable.toImmutableList
import tachiyomi.domain.manga.interactor.FetchInterval
import tachiyomi.i18n.MR
import tachiyomi.presentation.core.components.WheelTextPicker
@@ -124,7 +123,7 @@ fun SetIntervalDialog(
it.toString()
}
}
.toImmutableList()
WheelTextPicker(
items = items,
size = size,
@@ -21,7 +21,6 @@ import eu.kanade.presentation.components.AppBarActions
import eu.kanade.presentation.components.AppBarTitle
import eu.kanade.presentation.components.DownloadDropdownMenu
import eu.kanade.presentation.manga.DownloadAction
import kotlinx.collections.immutable.persistentListOf
import tachiyomi.i18n.MR
import tachiyomi.presentation.core.i18n.stringResource
import tachiyomi.presentation.core.theme.active
@@ -76,7 +75,7 @@ fun MangaToolbar(
val filterTint = if (hasFilters) MaterialTheme.colorScheme.active else LocalContentColor.current
AppBarActions(
actions = persistentListOf<AppBar.AppBarAction>().builder().apply {
actions = buildList {
if (isActionMode) {
add(
AppBar.Action(
@@ -92,7 +91,7 @@ fun MangaToolbar(
onClick = onInvertSelection,
),
)
return@apply
return@buildList
}
if (onClickDownload != null) {
add(
@@ -147,8 +146,7 @@ fun MangaToolbar(
onClick = onClickEditNotes,
),
)
}
.build(),
},
)
},
isActionMode = isActionMode,
@@ -5,8 +5,6 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.graphics.vector.ImageVector
import eu.kanade.tachiyomi.data.track.Tracker
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.ImmutableMap
import tachiyomi.i18n.MR
import tachiyomi.presentation.core.i18n.stringResource
import tachiyomi.core.common.preference.Preference as PreferenceData
@@ -69,10 +67,10 @@ sealed class Preference {
@Suppress("UNCHECKED_CAST")
data class ListPreference<T>(
val preference: PreferenceData<T>,
val entries: ImmutableMap<T, String>,
val entries: Map<T, String>,
override val title: String,
override val subtitle: String? = "%s",
val subtitleProvider: @Composable (value: T, entries: ImmutableMap<T, String>) -> String? =
val subtitleProvider: @Composable (value: T, entries: Map<T, String>) -> String? =
{ v, e -> subtitle?.format(e[v]) },
override val icon: ImageVector? = null,
override val enabled: Boolean = true,
@@ -82,8 +80,8 @@ sealed class Preference {
internal suspend fun internalOnValueChanged(value: Any) = onValueChanged(value as T)
@Composable
internal fun internalSubtitleProvider(value: Any?, entries: ImmutableMap<out Any?, String>) =
subtitleProvider(value as T, entries as ImmutableMap<T, String>)
internal fun internalSubtitleProvider(value: Any?, entries: Map<out Any?, String>) =
subtitleProvider(value as T, entries as Map<T, String>)
}
/**
@@ -91,10 +89,10 @@ sealed class Preference {
*/
data class BasicListPreference(
val value: String,
val entries: ImmutableMap<String, String>,
val entries: Map<String, String>,
override val title: String,
override val subtitle: String? = "%s",
val subtitleProvider: @Composable (value: String, entries: ImmutableMap<String, String>) -> String? =
val subtitleProvider: @Composable (value: String, entries: Map<String, String>) -> String? =
{ v, e -> subtitle?.format(e[v]) },
override val icon: ImageVector? = null,
override val enabled: Boolean = true,
@@ -107,10 +105,10 @@ sealed class Preference {
*/
data class MultiSelectListPreference(
val preference: PreferenceData<Set<String>>,
val entries: ImmutableMap<String, String>,
val entries: Map<String, String>,
override val title: String,
override val subtitle: String? = "%s",
val subtitleProvider: @Composable (value: Set<String>, entries: ImmutableMap<String, String>) -> String? =
val subtitleProvider: @Composable (value: Set<String>, entries: Map<String, String>) -> String? =
{ v, e ->
val combined = remember(v, e) {
v.mapNotNull { e[it] }
@@ -177,6 +175,6 @@ sealed class Preference {
override val title: String,
override val enabled: Boolean = true,
val preferenceItems: ImmutableList<PreferenceItem<out Any, out Any>>,
val preferenceItems: List<PreferenceItem<out Any, out Any>>,
) : Preference()
}
@@ -53,9 +53,6 @@ import eu.kanade.tachiyomi.util.system.isShizukuInstalled
import eu.kanade.tachiyomi.util.system.powerManager
import eu.kanade.tachiyomi.util.system.setDefaultSettings
import eu.kanade.tachiyomi.util.system.toast
import kotlinx.collections.immutable.persistentListOf
import kotlinx.collections.immutable.persistentMapOf
import kotlinx.collections.immutable.toImmutableMap
import kotlinx.coroutines.launch
import logcat.LogPriority
import okhttp3.Headers
@@ -140,7 +137,7 @@ object SettingsAdvancedScreen : SearchableSettings {
return Preference.PreferenceGroup(
title = stringResource(MR.strings.label_background_activity),
preferenceItems = persistentListOf(
preferenceItems = listOf(
Preference.PreferenceItem.TextPreference(
title = stringResource(MR.strings.pref_disable_battery_optimization),
subtitle = stringResource(MR.strings.pref_disable_battery_optimization_summary),
@@ -179,7 +176,7 @@ object SettingsAdvancedScreen : SearchableSettings {
return Preference.PreferenceGroup(
title = stringResource(MR.strings.label_data),
preferenceItems = persistentListOf(
preferenceItems = listOf(
Preference.PreferenceItem.TextPreference(
title = stringResource(MR.strings.pref_invalidate_download_cache),
subtitle = stringResource(MR.strings.pref_invalidate_download_cache_summary),
@@ -209,7 +206,7 @@ object SettingsAdvancedScreen : SearchableSettings {
return Preference.PreferenceGroup(
title = stringResource(MR.strings.label_network),
preferenceItems = persistentListOf(
preferenceItems = listOf(
Preference.PreferenceItem.TextPreference(
title = stringResource(MR.strings.pref_clear_cookies),
onClick = {
@@ -239,7 +236,7 @@ object SettingsAdvancedScreen : SearchableSettings {
),
Preference.PreferenceItem.ListPreference(
preference = networkPreferences.dohProvider,
entries = persistentMapOf(
entries = mapOf(
-1 to stringResource(MR.strings.disabled),
PREF_DOH_CLOUDFLARE to "Cloudflare",
PREF_DOH_GOOGLE to "Google",
@@ -296,7 +293,7 @@ object SettingsAdvancedScreen : SearchableSettings {
return Preference.PreferenceGroup(
title = stringResource(MR.strings.label_library),
preferenceItems = persistentListOf(
preferenceItems = listOf(
Preference.PreferenceItem.TextPreference(
title = stringResource(MR.strings.pref_refresh_library_covers),
onClick = { MetadataUpdateJob.startNow(context) },
@@ -348,7 +345,7 @@ object SettingsAdvancedScreen : SearchableSettings {
}
return Preference.PreferenceGroup(
title = stringResource(MR.strings.pref_category_reader),
preferenceItems = persistentListOf(
preferenceItems = listOf(
Preference.PreferenceItem.ListPreference(
preference = basePreferences.hardwareBitmapThreshold,
entries = GLUtil.CUSTOM_TEXTURE_LIMIT_OPTIONS
@@ -360,8 +357,7 @@ object SettingsAdvancedScreen : SearchableSettings {
}
option to display
}
.toMap()
.toImmutableMap(),
.toMap(),
title = stringResource(MR.strings.pref_hardware_bitmap_threshold),
subtitleProvider = { value, options ->
stringResource(MR.strings.pref_hardware_bitmap_threshold_summary, options[value].orEmpty())
@@ -420,7 +416,7 @@ object SettingsAdvancedScreen : SearchableSettings {
}
return Preference.PreferenceGroup(
title = stringResource(MR.strings.label_extensions),
preferenceItems = persistentListOf(
preferenceItems = listOf(
Preference.PreferenceItem.ListPreference(
preference = extensionInstallerPref,
entries = extensionInstallerPref.entries
@@ -432,8 +428,7 @@ object SettingsAdvancedScreen : SearchableSettings {
true
}
}
.associateWith { stringResource(it.titleRes) }
.toImmutableMap(),
.associateWith { stringResource(it.titleRes) },
title = stringResource(MR.strings.ext_installer_pref),
onValueChanged = {
if (it == BasePreferences.ExtensionInstaller.SHIZUKU &&
@@ -19,8 +19,6 @@ import eu.kanade.presentation.more.settings.screen.appearance.AppLanguageScreen
import eu.kanade.presentation.more.settings.widget.AppThemeModePreferenceWidget
import eu.kanade.presentation.more.settings.widget.AppThemePreferenceWidget
import eu.kanade.tachiyomi.util.system.toast
import kotlinx.collections.immutable.persistentListOf
import kotlinx.collections.immutable.toImmutableMap
import tachiyomi.i18n.MR
import tachiyomi.presentation.core.i18n.stringResource
import tachiyomi.presentation.core.util.collectAsState
@@ -61,7 +59,7 @@ object SettingsAppearanceScreen : SearchableSettings {
return Preference.PreferenceGroup(
title = stringResource(MR.strings.pref_category_theme),
preferenceItems = persistentListOf(
preferenceItems = listOf(
Preference.PreferenceItem.CustomPreference(
title = stringResource(MR.strings.pref_app_theme),
) {
@@ -110,7 +108,7 @@ object SettingsAppearanceScreen : SearchableSettings {
return Preference.PreferenceGroup(
title = stringResource(MR.strings.pref_category_display),
preferenceItems = persistentListOf(
preferenceItems = listOf(
Preference.PreferenceItem.TextPreference(
title = stringResource(MR.strings.pref_app_language),
onClick = { navigator.push(AppLanguageScreen()) },
@@ -118,8 +116,7 @@ object SettingsAppearanceScreen : SearchableSettings {
Preference.PreferenceItem.ListPreference(
preference = uiPreferences.tabletUiMode,
entries = TabletUiMode.entries
.associateWith { stringResource(it.titleRes) }
.toImmutableMap(),
.associateWith { stringResource(it.titleRes) },
title = stringResource(MR.strings.pref_tablet_ui_mode),
onValueChanged = {
context.toast(MR.strings.requires_app_restart)
@@ -132,8 +129,7 @@ object SettingsAppearanceScreen : SearchableSettings {
.associateWith {
val formattedDate = UiPreferences.dateFormat(it).format(now)
"${it.ifEmpty { stringResource(MR.strings.label_default) }} ($formattedDate)"
}
.toImmutableMap(),
},
title = stringResource(MR.strings.pref_date_format),
),
Preference.PreferenceItem.SwitchPreference(
@@ -13,7 +13,6 @@ import eu.kanade.domain.source.service.SourcePreferences
import eu.kanade.presentation.more.settings.Preference
import eu.kanade.presentation.more.settings.screen.browse.ExtensionStoresScreen
import eu.kanade.tachiyomi.util.system.AuthenticatorUtil.authenticate
import kotlinx.collections.immutable.persistentListOf
import mihon.domain.extension.interactor.GetExtensionStoreCountAsFlow
import tachiyomi.core.common.i18n.stringResource
import tachiyomi.i18n.MR
@@ -41,7 +40,7 @@ object SettingsBrowseScreen : SearchableSettings {
return listOf(
Preference.PreferenceGroup(
title = stringResource(MR.strings.label_sources),
preferenceItems = persistentListOf(
preferenceItems = listOf(
Preference.PreferenceItem.SwitchPreference(
preference = sourcePreferences.hideInLibraryItems,
title = stringResource(MR.strings.pref_hide_in_library_items),
@@ -57,7 +56,7 @@ object SettingsBrowseScreen : SearchableSettings {
),
Preference.PreferenceGroup(
title = stringResource(MR.strings.pref_category_nsfw_content),
preferenceItems = persistentListOf(
preferenceItems = listOf(
Preference.PreferenceItem.SwitchPreference(
preference = sourcePreferences.showNsfwSource,
title = stringResource(MR.strings.pref_show_nsfw_source),
@@ -56,8 +56,6 @@ import eu.kanade.tachiyomi.data.export.LibraryExporter
import eu.kanade.tachiyomi.data.export.LibraryExporter.ExportOptions
import eu.kanade.tachiyomi.util.system.DeviceUtil
import eu.kanade.tachiyomi.util.system.toast
import kotlinx.collections.immutable.persistentListOf
import kotlinx.collections.immutable.persistentMapOf
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import logcat.LogPriority
@@ -103,7 +101,7 @@ object SettingsDataScreen : SearchableSettings {
val backupPreferences = Injekt.get<BackupPreferences>()
val storagePreferences = Injekt.get<StoragePreferences>()
return persistentListOf(
return listOf(
getStorageLocationPref(storagePreferences = storagePreferences),
Preference.PreferenceItem.InfoPreference(stringResource(MR.strings.pref_storage_location_info)),
@@ -207,7 +205,7 @@ object SettingsDataScreen : SearchableSettings {
return Preference.PreferenceGroup(
title = stringResource(MR.strings.label_backup),
preferenceItems = persistentListOf(
preferenceItems = listOf(
// Manual actions
Preference.PreferenceItem.CustomPreference(
title = stringResource(restorePreferenceKeyString),
@@ -255,7 +253,7 @@ object SettingsDataScreen : SearchableSettings {
// Automatic backups
Preference.PreferenceItem.ListPreference(
preference = backupPreferences.backupInterval,
entries = persistentMapOf(
entries = mapOf(
0 to stringResource(MR.strings.off),
6 to stringResource(MR.strings.update_6hour),
12 to stringResource(MR.strings.update_12hour),
@@ -289,7 +287,7 @@ object SettingsDataScreen : SearchableSettings {
return Preference.PreferenceGroup(
title = stringResource(MR.strings.pref_storage_usage),
preferenceItems = persistentListOf(
preferenceItems = listOf(
Preference.PreferenceItem.CustomPreference(
title = stringResource(MR.strings.pref_storage_usage),
) {
@@ -382,7 +380,7 @@ object SettingsDataScreen : SearchableSettings {
return Preference.PreferenceGroup(
title = stringResource(MR.strings.export),
preferenceItems = persistentListOf(
preferenceItems = listOf(
Preference.PreferenceItem.TextPreference(
title = stringResource(MR.strings.library_list),
onClick = { showDialog = true },
@@ -12,9 +12,6 @@ import androidx.compose.ui.util.fastMap
import eu.kanade.presentation.category.visualName
import eu.kanade.presentation.more.settings.Preference
import eu.kanade.presentation.more.settings.widget.TriStateListDialog
import kotlinx.collections.immutable.persistentListOf
import kotlinx.collections.immutable.persistentMapOf
import kotlinx.collections.immutable.toImmutableMap
import tachiyomi.domain.category.interactor.GetCategories
import tachiyomi.domain.category.model.Category
import tachiyomi.domain.download.service.DownloadPreferences
@@ -85,14 +82,14 @@ object SettingsDownloadScreen : SearchableSettings {
): Preference.PreferenceGroup {
return Preference.PreferenceGroup(
title = stringResource(MR.strings.pref_category_delete_chapters),
preferenceItems = persistentListOf(
preferenceItems = listOf(
Preference.PreferenceItem.SwitchPreference(
preference = downloadPreferences.removeAfterMarkedAsRead,
title = stringResource(MR.strings.pref_remove_after_marked_as_read),
),
Preference.PreferenceItem.ListPreference(
preference = downloadPreferences.removeAfterReadSlots,
entries = persistentMapOf(
entries = mapOf(
-1 to stringResource(MR.strings.disabled),
0 to stringResource(MR.strings.last_read_chapter),
1 to stringResource(MR.strings.second_to_last),
@@ -122,8 +119,7 @@ object SettingsDownloadScreen : SearchableSettings {
return Preference.PreferenceItem.MultiSelectListPreference(
preference = downloadPreferences.removeExcludeCategories,
entries = categories()
.associate { it.id.toString() to it.visualName }
.toImmutableMap(),
.associate { it.id.toString() to it.visualName },
title = stringResource(MR.strings.pref_remove_exclude_categories),
)
}
@@ -162,7 +158,7 @@ object SettingsDownloadScreen : SearchableSettings {
return Preference.PreferenceGroup(
title = stringResource(MR.strings.pref_category_auto_download),
preferenceItems = persistentListOf(
preferenceItems = listOf(
Preference.PreferenceItem.SwitchPreference(
preference = downloadNewChaptersPref,
title = stringResource(MR.strings.pref_download_new),
@@ -192,7 +188,7 @@ object SettingsDownloadScreen : SearchableSettings {
): Preference.PreferenceGroup {
return Preference.PreferenceGroup(
title = stringResource(MR.strings.download_ahead),
preferenceItems = persistentListOf(
preferenceItems = listOf(
Preference.PreferenceItem.ListPreference(
preference = downloadPreferences.autoDownloadWhileReading,
entries = listOf(0, 2, 3, 5, 10)
@@ -202,8 +198,7 @@ object SettingsDownloadScreen : SearchableSettings {
} else {
pluralStringResource(MR.plurals.next_unread_chapters, count = it, it)
}
}
.toImmutableMap(),
},
title = stringResource(MR.strings.auto_download_while_reading),
),
Preference.PreferenceItem.InfoPreference(stringResource(MR.strings.download_ahead_info)),
@@ -20,9 +20,6 @@ import eu.kanade.presentation.more.settings.Preference
import eu.kanade.presentation.more.settings.widget.TriStateListDialog
import eu.kanade.tachiyomi.data.library.LibraryUpdateJob
import eu.kanade.tachiyomi.ui.category.CategoryScreen
import kotlinx.collections.immutable.persistentListOf
import kotlinx.collections.immutable.persistentMapOf
import kotlinx.collections.immutable.toImmutableMap
import kotlinx.coroutines.launch
import tachiyomi.domain.category.interactor.GetCategories
import tachiyomi.domain.category.interactor.ResetCategoryFlags
@@ -80,7 +77,7 @@ object SettingsLibraryScreen : SearchableSettings {
return Preference.PreferenceGroup(
title = stringResource(MR.strings.categories),
preferenceItems = persistentListOf(
preferenceItems = listOf(
Preference.PreferenceItem.TextPreference(
title = stringResource(MR.strings.action_edit_categories),
subtitle = pluralStringResource(
@@ -92,7 +89,7 @@ object SettingsLibraryScreen : SearchableSettings {
),
Preference.PreferenceItem.ListPreference(
preference = libraryPreferences.defaultCategory,
entries = ids.zip(labels).toMap().toImmutableMap(),
entries = ids.zip(labels).toMap(),
title = stringResource(MR.strings.default_category),
),
Preference.PreferenceItem.SwitchPreference(
@@ -146,10 +143,10 @@ object SettingsLibraryScreen : SearchableSettings {
return Preference.PreferenceGroup(
title = stringResource(MR.strings.pref_category_library_update),
preferenceItems = persistentListOf(
preferenceItems = listOf(
Preference.PreferenceItem.ListPreference(
preference = autoUpdateIntervalPref,
entries = persistentMapOf(
entries = mapOf(
0 to stringResource(MR.strings.update_never),
12 to stringResource(MR.strings.update_12hour),
24 to stringResource(MR.strings.update_24hour),
@@ -165,7 +162,7 @@ object SettingsLibraryScreen : SearchableSettings {
),
Preference.PreferenceItem.MultiSelectListPreference(
preference = libraryPreferences.autoUpdateDeviceRestrictions,
entries = persistentMapOf(
entries = mapOf(
DEVICE_ONLY_ON_WIFI to stringResource(MR.strings.connected_to_wifi),
DEVICE_NETWORK_NOT_METERED to stringResource(MR.strings.network_not_metered),
DEVICE_CHARGING to stringResource(MR.strings.charging),
@@ -195,7 +192,7 @@ object SettingsLibraryScreen : SearchableSettings {
),
Preference.PreferenceItem.MultiSelectListPreference(
preference = libraryPreferences.autoUpdateMangaRestrictions,
entries = persistentMapOf(
entries = mapOf(
MANGA_HAS_UNREAD to stringResource(MR.strings.pref_update_only_completely_read),
MANGA_NON_READ to stringResource(MR.strings.pref_update_only_started),
MANGA_NON_COMPLETED to stringResource(MR.strings.pref_update_only_non_completed),
@@ -217,10 +214,10 @@ object SettingsLibraryScreen : SearchableSettings {
): Preference.PreferenceGroup {
return Preference.PreferenceGroup(
title = stringResource(MR.strings.pref_behavior),
preferenceItems = persistentListOf(
preferenceItems = listOf(
Preference.PreferenceItem.ListPreference(
preference = libraryPreferences.swipeToStartAction,
entries = persistentMapOf(
entries = mapOf(
LibraryPreferences.ChapterSwipeAction.Disabled to
stringResource(MR.strings.disabled),
LibraryPreferences.ChapterSwipeAction.ToggleBookmark to
@@ -234,7 +231,7 @@ object SettingsLibraryScreen : SearchableSettings {
),
Preference.PreferenceItem.ListPreference(
preference = libraryPreferences.swipeToEndAction,
entries = persistentMapOf(
entries = mapOf(
LibraryPreferences.ChapterSwipeAction.Disabled to
stringResource(MR.strings.disabled),
LibraryPreferences.ChapterSwipeAction.ToggleBookmark to
@@ -248,7 +245,7 @@ object SettingsLibraryScreen : SearchableSettings {
),
Preference.PreferenceItem.MultiSelectListPreference(
preference = libraryPreferences.markDuplicateReadChapterAsRead,
entries = persistentMapOf(
entries = mapOf(
MARK_DUPLICATE_CHAPTER_READ_EXISTING to
stringResource(MR.strings.pref_mark_duplicate_read_chapter_read_existing),
MARK_DUPLICATE_CHAPTER_READ_NEW to
@@ -44,7 +44,6 @@ import eu.kanade.presentation.more.settings.screen.about.AboutScreen
import eu.kanade.presentation.more.settings.widget.TextPreferenceWidget
import eu.kanade.presentation.util.LocalBackPress
import eu.kanade.presentation.util.Screen
import kotlinx.collections.immutable.persistentListOf
import tachiyomi.i18n.MR
import tachiyomi.presentation.core.components.material.Scaffold
import tachiyomi.presentation.core.i18n.stringResource
@@ -88,7 +87,7 @@ object SettingsMainScreen : Screen() {
navigateUp = backPress::invoke,
actions = {
AppBarActions(
persistentListOf(
listOf(
AppBar.Action(
title = stringResource(MR.strings.action_search),
icon = Icons.Outlined.Search,
@@ -10,9 +10,6 @@ import eu.kanade.tachiyomi.ui.reader.setting.ReaderOrientation
import eu.kanade.tachiyomi.ui.reader.setting.ReaderPreferences
import eu.kanade.tachiyomi.ui.reader.setting.ReadingMode
import eu.kanade.tachiyomi.util.system.hasDisplayCutout
import kotlinx.collections.immutable.persistentListOf
import kotlinx.collections.immutable.persistentMapOf
import kotlinx.collections.immutable.toImmutableMap
import tachiyomi.i18n.MR
import tachiyomi.presentation.core.i18n.pluralStringResource
import tachiyomi.presentation.core.i18n.stringResource
@@ -35,13 +32,12 @@ object SettingsReaderScreen : SearchableSettings {
Preference.PreferenceItem.ListPreference(
preference = readerPref.defaultReadingMode,
entries = ReadingMode.entries.drop(1)
.associate { it.flagValue to stringResource(it.stringRes) }
.toImmutableMap(),
.associate { it.flagValue to stringResource(it.stringRes) },
title = stringResource(MR.strings.pref_viewer_type),
),
Preference.PreferenceItem.ListPreference(
preference = readerPref.doubleTapAnimSpeed,
entries = persistentMapOf(
entries = mapOf(
1 to stringResource(MR.strings.double_tap_anim_speed_0),
500 to stringResource(MR.strings.double_tap_anim_speed_normal),
250 to stringResource(MR.strings.double_tap_anim_speed_fast),
@@ -78,17 +74,16 @@ object SettingsReaderScreen : SearchableSettings {
val verticalNavigatorForLongStrip by readerPreferences.verticalNavigatorForLongStrip.collectAsState()
return Preference.PreferenceGroup(
title = stringResource(MR.strings.pref_category_display),
preferenceItems = persistentListOf(
preferenceItems = listOf(
Preference.PreferenceItem.ListPreference(
preference = readerPreferences.defaultOrientationType,
entries = ReaderOrientation.entries.drop(1)
.associate { it.flagValue to stringResource(it.stringRes) }
.toImmutableMap(),
.associate { it.flagValue to stringResource(it.stringRes) },
title = stringResource(MR.strings.pref_rotation_type),
),
Preference.PreferenceItem.ListPreference(
preference = readerPreferences.readerTheme,
entries = persistentMapOf(
entries = mapOf(
1 to stringResource(MR.strings.black_background),
2 to stringResource(MR.strings.gray_background),
0 to stringResource(MR.strings.white_background),
@@ -140,7 +135,7 @@ object SettingsReaderScreen : SearchableSettings {
return Preference.PreferenceGroup(
title = "E-Ink",
preferenceItems = persistentListOf(
preferenceItems = listOf(
Preference.PreferenceItem.SwitchPreference(
preference = readerPreferences.flashOnPageChange,
title = stringResource(MR.strings.pref_flash_page),
@@ -164,7 +159,7 @@ object SettingsReaderScreen : SearchableSettings {
),
Preference.PreferenceItem.ListPreference(
preference = flashColorPref,
entries = persistentMapOf(
entries = mapOf(
ReaderPreferences.FlashColor.BLACK to stringResource(MR.strings.pref_flash_style_black),
ReaderPreferences.FlashColor.WHITE to stringResource(MR.strings.pref_flash_style_white),
ReaderPreferences.FlashColor.WHITE_BLACK
@@ -181,7 +176,7 @@ object SettingsReaderScreen : SearchableSettings {
private fun getReadingGroup(readerPreferences: ReaderPreferences): Preference.PreferenceGroup {
return Preference.PreferenceGroup(
title = stringResource(MR.strings.pref_category_reading),
preferenceItems = persistentListOf(
preferenceItems = listOf(
Preference.PreferenceItem.SwitchPreference(
preference = readerPreferences.skipRead,
title = stringResource(MR.strings.pref_skip_read_chapters),
@@ -216,25 +211,23 @@ object SettingsReaderScreen : SearchableSettings {
return Preference.PreferenceGroup(
title = stringResource(MR.strings.pager_viewer),
preferenceItems = persistentListOf(
preferenceItems = listOf(
Preference.PreferenceItem.ListPreference(
preference = navModePref,
entries = ReaderPreferences.TapZones
.mapIndexed { index, it -> index to stringResource(it) }
.toMap()
.toImmutableMap(),
.toMap(),
title = stringResource(MR.strings.pref_viewer_nav),
),
Preference.PreferenceItem.ListPreference(
preference = readerPreferences.pagerNavInverted,
entries = persistentListOf(
entries = listOf(
ReaderPreferences.TappingInvertMode.NONE,
ReaderPreferences.TappingInvertMode.HORIZONTAL,
ReaderPreferences.TappingInvertMode.VERTICAL,
ReaderPreferences.TappingInvertMode.BOTH,
)
.associateWith { stringResource(it.titleRes) }
.toImmutableMap(),
.associateWith { stringResource(it.titleRes) },
title = stringResource(MR.strings.pref_read_with_tapping_inverted),
enabled = navMode != 5,
),
@@ -242,16 +235,14 @@ object SettingsReaderScreen : SearchableSettings {
preference = imageScaleTypePref,
entries = ReaderPreferences.ImageScaleType
.mapIndexed { index, it -> index + 1 to stringResource(it) }
.toMap()
.toImmutableMap(),
.toMap(),
title = stringResource(MR.strings.pref_image_scale_type),
),
Preference.PreferenceItem.ListPreference(
preference = readerPreferences.zoomStart,
entries = ReaderPreferences.ZoomStart
.mapIndexed { index, it -> index + 1 to stringResource(it) }
.toMap()
.toImmutableMap(),
.toMap(),
title = stringResource(MR.strings.pref_zoom_start),
),
Preference.PreferenceItem.SwitchPreference(
@@ -315,25 +306,23 @@ object SettingsReaderScreen : SearchableSettings {
return Preference.PreferenceGroup(
title = stringResource(MR.strings.webtoon_viewer),
preferenceItems = persistentListOf(
preferenceItems = listOf(
Preference.PreferenceItem.ListPreference(
preference = navModePref,
entries = ReaderPreferences.TapZones
.mapIndexed { index, it -> index to stringResource(it) }
.toMap()
.toImmutableMap(),
.toMap(),
title = stringResource(MR.strings.pref_viewer_nav),
),
Preference.PreferenceItem.ListPreference(
preference = readerPreferences.webtoonNavInverted,
entries = persistentListOf(
entries = listOf(
ReaderPreferences.TappingInvertMode.NONE,
ReaderPreferences.TappingInvertMode.HORIZONTAL,
ReaderPreferences.TappingInvertMode.VERTICAL,
ReaderPreferences.TappingInvertMode.BOTH,
)
.associateWith { stringResource(it.titleRes) }
.toImmutableMap(),
.associateWith { stringResource(it.titleRes) },
title = stringResource(MR.strings.pref_read_with_tapping_inverted),
enabled = navMode != 5,
),
@@ -348,7 +337,7 @@ object SettingsReaderScreen : SearchableSettings {
),
Preference.PreferenceItem.ListPreference(
preference = readerPreferences.readerHideThreshold,
entries = persistentMapOf(
entries = mapOf(
ReaderPreferences.ReaderHideThreshold.HIGHEST to stringResource(MR.strings.pref_highest),
ReaderPreferences.ReaderHideThreshold.HIGH to stringResource(MR.strings.pref_high),
ReaderPreferences.ReaderHideThreshold.LOW to stringResource(MR.strings.pref_low),
@@ -405,7 +394,7 @@ object SettingsReaderScreen : SearchableSettings {
val readWithVolumeKeys by readWithVolumeKeysPref.collectAsState()
return Preference.PreferenceGroup(
title = stringResource(MR.strings.pref_reader_navigation),
preferenceItems = persistentListOf(
preferenceItems = listOf(
Preference.PreferenceItem.SwitchPreference(
preference = readWithVolumeKeysPref,
title = stringResource(MR.strings.pref_read_with_volume_keys),
@@ -423,7 +412,7 @@ object SettingsReaderScreen : SearchableSettings {
private fun getActionsGroup(readerPreferences: ReaderPreferences): Preference.PreferenceGroup {
return Preference.PreferenceGroup(
title = stringResource(MR.strings.pref_reader_actions),
preferenceItems = persistentListOf(
preferenceItems = listOf(
Preference.PreferenceItem.SwitchPreference(
preference = readerPreferences.readWithLongTap,
title = stringResource(MR.strings.pref_read_with_long_tap),
@@ -12,8 +12,6 @@ import eu.kanade.tachiyomi.core.security.SecurityPreferences
import eu.kanade.tachiyomi.util.system.AuthenticatorUtil.authenticate
import eu.kanade.tachiyomi.util.system.AuthenticatorUtil.isAuthenticationSupported
import eu.kanade.tachiyomi.util.system.telemetryIncluded
import kotlinx.collections.immutable.persistentListOf
import kotlinx.collections.immutable.toImmutableMap
import tachiyomi.core.common.i18n.stringResource
import tachiyomi.i18n.MR
import tachiyomi.presentation.core.i18n.pluralStringResource
@@ -50,7 +48,7 @@ object SettingsSecurityScreen : SearchableSettings {
return Preference.PreferenceGroup(
title = stringResource(MR.strings.pref_security),
preferenceItems = persistentListOf(
preferenceItems = listOf(
Preference.PreferenceItem.SwitchPreference(
preference = useAuthPref,
title = stringResource(MR.strings.lock_with_biometrics),
@@ -70,8 +68,7 @@ object SettingsSecurityScreen : SearchableSettings {
0 -> stringResource(MR.strings.lock_always)
else -> pluralStringResource(MR.plurals.lock_after_mins, count = it, it)
}
}
.toImmutableMap(),
},
title = stringResource(MR.strings.lock_when_idle),
enabled = authSupported && useAuth,
onValueChanged = {
@@ -88,8 +85,7 @@ object SettingsSecurityScreen : SearchableSettings {
Preference.PreferenceItem.ListPreference(
preference = securityPreferences.secureScreen,
entries = SecurityPreferences.SecureScreenMode.entries
.associateWith { stringResource(it.titleRes) }
.toImmutableMap(),
.associateWith { stringResource(it.titleRes) },
title = stringResource(MR.strings.secure_screen),
),
Preference.PreferenceItem.InfoPreference(stringResource(MR.strings.secure_screen_summary)),
@@ -103,7 +99,7 @@ object SettingsSecurityScreen : SearchableSettings {
): Preference.PreferenceGroup {
return Preference.PreferenceGroup(
title = stringResource(MR.strings.pref_firebase),
preferenceItems = persistentListOf(
preferenceItems = listOf(
Preference.PreferenceItem.SwitchPreference(
preference = privacyPreferences.crashlytics,
title = stringResource(MR.strings.onboarding_permission_crashlytics),
@@ -120,7 +116,7 @@ object SettingsSecurityScreen : SearchableSettings {
}
}
private val LockAfterValues = persistentListOf(
private val LockAfterValues = listOf(
0, // Always
1,
2,
@@ -55,9 +55,6 @@ import eu.kanade.tachiyomi.data.track.myanimelist.MyAnimeListApi
import eu.kanade.tachiyomi.data.track.shikimori.ShikimoriApi
import eu.kanade.tachiyomi.util.system.openInBrowser
import eu.kanade.tachiyomi.util.system.toast
import kotlinx.collections.immutable.persistentListOf
import kotlinx.collections.immutable.toImmutableList
import kotlinx.collections.immutable.toPersistentMap
import tachiyomi.core.common.util.lang.launchIO
import tachiyomi.core.common.util.lang.withUIContext
import tachiyomi.domain.source.service.SourceManager
@@ -134,13 +131,12 @@ object SettingsTrackingScreen : SearchableSettings {
Preference.PreferenceItem.ListPreference(
preference = trackPreferences.autoUpdateTrackOnMarkRead,
entries = AutoTrackState.entries
.associateWith { stringResource(it.titleRes) }
.toPersistentMap(),
.associateWith { stringResource(it.titleRes) },
title = stringResource(MR.strings.pref_auto_update_manga_on_mark_read),
),
Preference.PreferenceGroup(
title = stringResource(MR.strings.services),
preferenceItems = persistentListOf(
preferenceItems = listOf(
Preference.PreferenceItem.TrackerPreference(
tracker = trackerManager.myAnimeList,
login = { context.openInBrowser(MyAnimeListApi.authUrl(), forceDefaultBrowser = true) },
@@ -185,7 +181,7 @@ object SettingsTrackingScreen : SearchableSettings {
logout = service::logout,
)
} + listOf(Preference.PreferenceItem.InfoPreference(enhancedTrackerInfo))
).toImmutableList(),
),
),
)
}
@@ -18,7 +18,6 @@ import com.google.android.material.textview.MaterialTextView
import eu.kanade.presentation.components.AppBar
import eu.kanade.presentation.components.AppBarActions
import eu.kanade.presentation.util.Screen
import kotlinx.collections.immutable.persistentListOf
import tachiyomi.i18n.MR
import tachiyomi.presentation.core.components.material.Scaffold
import tachiyomi.presentation.core.i18n.stringResource
@@ -42,7 +41,7 @@ class OpenSourceLibraryLicenseScreen(
actions = {
if (!website.isNullOrEmpty()) {
AppBarActions(
persistentListOf(
listOf(
AppBar.Action(
title = stringResource(MR.strings.website),
icon = Icons.Default.Public,
@@ -40,7 +40,6 @@ import eu.kanade.presentation.components.AppBar
import eu.kanade.presentation.components.AppBarActions
import eu.kanade.presentation.util.Screen
import eu.kanade.tachiyomi.util.system.toast
import kotlinx.collections.immutable.persistentListOf
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.update
import tachiyomi.core.common.util.lang.launchIO
@@ -140,7 +139,7 @@ class ClearDatabaseScreen : Screen() {
actions = {
if (s.items.isNotEmpty()) {
AppBarActions(
actions = persistentListOf(
actions = listOf(
AppBar.Action(
title = stringResource(MR.strings.action_select_all),
icon = Icons.Outlined.SelectAll,
@@ -27,8 +27,6 @@ import eu.kanade.presentation.components.AppBar
import eu.kanade.presentation.util.Screen
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.util.system.LocaleHelper
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.toImmutableList
import org.xmlpull.v1.XmlPullParser
import tachiyomi.core.common.i18n.stringResource
import tachiyomi.i18n.MR
@@ -94,8 +92,7 @@ class AppLanguageScreen : Screen() {
}
}
private fun getLangs(context: Context): ImmutableList<Language> {
val langs = mutableListOf<Language>()
private fun getLangs(context: Context): List<Language> = buildList {
val parser = context.resources.getXml(R.xml.locales_config)
var eventType = parser.eventType
while (eventType != XmlPullParser.END_DOCUMENT) {
@@ -105,7 +102,7 @@ class AppLanguageScreen : Screen() {
val langTag = parser.getAttributeValue(i)
val displayName = LocaleHelper.getLocalizedDisplayName(langTag)
if (displayName.isNotEmpty()) {
langs.add(Language(langTag, displayName, LocaleHelper.getDisplayName(langTag)))
add(Language(langTag, displayName, LocaleHelper.getDisplayName(langTag)))
}
}
}
@@ -113,10 +110,8 @@ class AppLanguageScreen : Screen() {
eventType = parser.next()
}
langs.sortBy { it.displayName }
langs.add(0, Language("", context.stringResource(MR.strings.label_default), null))
return langs.toImmutableList()
sortBy { it.displayName }
add(0, Language("", context.stringResource(MR.strings.label_default), null))
}
private data class Language(
@@ -23,7 +23,6 @@ import eu.kanade.tachiyomi.data.backup.create.BackupCreator
import eu.kanade.tachiyomi.data.backup.create.BackupOptions
import eu.kanade.tachiyomi.util.system.DeviceUtil
import eu.kanade.tachiyomi.util.system.toast
import kotlinx.collections.immutable.ImmutableList
import kotlinx.coroutines.flow.update
import tachiyomi.i18n.MR
import tachiyomi.presentation.core.components.LabeledCheckbox
@@ -103,7 +102,7 @@ class CreateBackupScreen : Screen() {
@Composable
private fun Options(
options: ImmutableList<BackupOptions.Entry>,
options: List<BackupOptions.Entry>,
state: CreateBackupScreenModel.State,
model: CreateBackupScreenModel,
) {
@@ -19,7 +19,6 @@ import eu.kanade.presentation.components.AppBarActions
import eu.kanade.presentation.util.Screen
import eu.kanade.tachiyomi.data.backup.models.Backup
import eu.kanade.tachiyomi.util.system.copyToClipboard
import kotlinx.collections.immutable.persistentListOf
import kotlinx.serialization.protobuf.schema.ProtoBufSchemaGenerator
import tachiyomi.i18n.MR
import tachiyomi.presentation.core.components.material.Scaffold
@@ -45,7 +44,7 @@ class BackupSchemaScreen : Screen() {
navigateUp = navigator::pop,
actions = {
AppBarActions(
persistentListOf(
listOf(
AppBar.Action(
title = stringResource(MR.strings.action_copy_to_clipboard),
icon = Icons.Default.ContentCopy,
@@ -24,8 +24,6 @@ import eu.kanade.presentation.util.Screen
import eu.kanade.tachiyomi.util.system.DeviceUtil
import eu.kanade.tachiyomi.util.system.WebViewUtil
import eu.kanade.tachiyomi.util.system.copyToClipboard
import kotlinx.collections.immutable.mutate
import kotlinx.collections.immutable.persistentListOf
import kotlinx.coroutines.guava.await
import kotlinx.coroutines.launch
import mihon.core.common.FeatureFlags
@@ -69,7 +67,7 @@ class DebugInfoScreen : Screen() {
return Preference.PreferenceGroup(
title = "App info",
preferenceItems = persistentListOf(
preferenceItems = listOf(
Preference.PreferenceItem.TextPreference(
title = "Version",
subtitle = AboutScreen.getVersionName(false),
@@ -141,8 +139,8 @@ class DebugInfoScreen : Screen() {
}
private fun getDeviceInfoGroup(): Preference.PreferenceGroup {
val items = persistentListOf<Preference.PreferenceItem<out Any, out Any>>().mutate {
it.add(
val items = buildList {
add(
Preference.PreferenceItem.TextPreference(
title = "Model",
subtitle = "${Build.MANUFACTURER} ${Build.MODEL} (${Build.DEVICE})",
@@ -150,14 +148,14 @@ class DebugInfoScreen : Screen() {
)
if (DeviceUtil.oneUiVersion != null) {
it.add(
add(
Preference.PreferenceItem.TextPreference(
title = "OneUI version",
subtitle = "${DeviceUtil.oneUiVersion}",
),
)
} else if (DeviceUtil.miuiMajorVersion != null) {
it.add(
add(
Preference.PreferenceItem.TextPreference(
title = "MIUI version",
subtitle = "${DeviceUtil.miuiMajorVersion}",
@@ -172,7 +170,7 @@ class DebugInfoScreen : Screen() {
} else {
Build.VERSION.RELEASE
}
it.add(
add(
Preference.PreferenceItem.TextPreference(
title = "Android version",
subtitle = "$androidVersion (${Build.DISPLAY})",
@@ -32,7 +32,6 @@ import eu.kanade.presentation.util.ioCoroutineScope
import eu.kanade.tachiyomi.util.lang.toDateTimestampString
import eu.kanade.tachiyomi.util.system.copyToClipboard
import eu.kanade.tachiyomi.util.system.workManager
import kotlinx.collections.immutable.persistentListOf
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.stateIn
@@ -69,7 +68,7 @@ class WorkerInfoScreen : Screen() {
navigateUp = navigator::pop,
actions = {
AppBarActions(
persistentListOf(
listOf(
AppBar.Action(
title = stringResource(MR.strings.action_copy_to_clipboard),
icon = Icons.Default.ContentCopy,
@@ -37,7 +37,6 @@ import eu.kanade.presentation.theme.TachiyomiPreviewTheme
import eu.kanade.tachiyomi.data.database.models.toDomainChapter
import eu.kanade.tachiyomi.ui.reader.model.ChapterTransition
import eu.kanade.tachiyomi.ui.reader.model.ReaderChapter
import kotlinx.collections.immutable.persistentMapOf
import tachiyomi.domain.chapter.model.Chapter
import tachiyomi.domain.chapter.service.calculateChapterGap
import tachiyomi.i18n.MR
@@ -235,7 +234,7 @@ private fun ChapterText(
maxLines = 5,
overflow = TextOverflow.Ellipsis,
style = MaterialTheme.typography.titleLarge,
inlineContent = persistentMapOf(
inlineContent = mapOf(
DOWNLOADED_ICON_ID to InlineTextContent(
Placeholder(
width = 22.sp,
@@ -8,7 +8,6 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import eu.kanade.presentation.components.AppBar
import eu.kanade.presentation.components.AppBarActions
import kotlinx.collections.immutable.persistentListOf
import tachiyomi.i18n.MR
import tachiyomi.presentation.core.i18n.stringResource
@@ -32,51 +31,49 @@ fun ReaderTopBar(
navigateUp = navigateUp,
actions = {
AppBarActions(
actions = persistentListOf<AppBar.AppBarAction>().builder()
.apply {
add(
AppBar.Action(
title = stringResource(
if (bookmarked) {
MR.strings.action_remove_bookmark
} else {
MR.strings.action_bookmark
},
),
icon = if (bookmarked) {
Icons.Outlined.Bookmark
actions = buildList {
add(
AppBar.Action(
title = stringResource(
if (bookmarked) {
MR.strings.action_remove_bookmark
} else {
Icons.Outlined.BookmarkBorder
MR.strings.action_bookmark
},
onClick = onToggleBookmarked,
),
icon = if (bookmarked) {
Icons.Outlined.Bookmark
} else {
Icons.Outlined.BookmarkBorder
},
onClick = onToggleBookmarked,
),
)
onOpenInWebView?.let {
add(
AppBar.OverflowAction(
title = stringResource(MR.strings.action_open_in_web_view),
onClick = it,
),
)
onOpenInWebView?.let {
add(
AppBar.OverflowAction(
title = stringResource(MR.strings.action_open_in_web_view),
onClick = it,
),
)
}
onOpenInBrowser?.let {
add(
AppBar.OverflowAction(
title = stringResource(MR.strings.action_open_in_browser),
onClick = it,
),
)
}
onShare?.let {
add(
AppBar.OverflowAction(
title = stringResource(MR.strings.action_share),
onClick = it,
),
)
}
}
.build(),
onOpenInBrowser?.let {
add(
AppBar.OverflowAction(
title = stringResource(MR.strings.action_open_in_browser),
onClick = it,
),
)
}
onShare?.let {
add(
AppBar.OverflowAction(
title = stringResource(MR.strings.action_share),
onClick = it,
),
)
}
},
)
},
)
@@ -15,7 +15,6 @@ import androidx.compose.ui.window.DialogWindowProvider
import eu.kanade.presentation.components.TabbedDialog
import eu.kanade.presentation.components.TabbedDialogPaddings
import eu.kanade.tachiyomi.ui.reader.setting.ReaderSettingsScreenModel
import kotlinx.collections.immutable.persistentListOf
import tachiyomi.i18n.MR
import tachiyomi.presentation.core.i18n.stringResource
@@ -26,7 +25,7 @@ fun ReaderSettingsDialog(
onHideMenus: () -> Unit,
screenModel: ReaderSettingsScreenModel,
) {
val tabTitles = persistentListOf(
val tabTitles = listOf(
stringResource(MR.strings.pref_category_reading_mode),
stringResource(MR.strings.pref_category_general),
stringResource(MR.strings.custom_filter),
@@ -33,9 +33,6 @@ import androidx.compose.ui.tooling.preview.PreviewLightDark
import androidx.compose.ui.unit.dp
import dev.icerock.moko.resources.StringResource
import eu.kanade.presentation.theme.TachiyomiPreviewTheme
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.persistentMapOf
import kotlinx.collections.immutable.toImmutableList
import tachiyomi.i18n.MR
import tachiyomi.presentation.core.components.ScrollbarLazyColumn
import tachiyomi.presentation.core.components.WheelNumberPicker
@@ -104,7 +101,7 @@ fun TrackChapterSelector(
title = stringResource(MR.strings.chapters),
content = {
WheelNumberPicker(
items = range.toImmutableList(),
items = range.toList(),
modifier = Modifier.align(Alignment.Center),
startIndex = selection,
onSelectionChanged = { onSelectionChange(it) },
@@ -119,7 +116,7 @@ fun TrackChapterSelector(
fun TrackScoreSelector(
selection: String,
onSelectionChange: (String) -> Unit,
selections: ImmutableList<String>,
selections: List<String>,
onConfirm: () -> Unit,
onDismissRequest: () -> Unit,
) {
@@ -232,7 +229,7 @@ private fun TrackStatusSelectorPreviews() {
TrackStatusSelector(
selection = 1,
onSelectionChange = {},
selections = persistentMapOf(
selections = mapOf(
// Anilist values
1L to MR.strings.reading,
2L to MR.strings.plan_to_read,
@@ -20,7 +20,6 @@ import androidx.compose.ui.Modifier
import eu.kanade.presentation.components.TabbedDialog
import eu.kanade.presentation.components.TabbedDialogPaddings
import eu.kanade.tachiyomi.ui.updates.UpdatesSettingsScreenModel
import kotlinx.collections.immutable.persistentListOf
import tachiyomi.core.common.preference.getAndSet
import tachiyomi.domain.updates.service.UpdatesPreferences
import tachiyomi.i18n.MR
@@ -37,7 +36,7 @@ fun UpdatesFilterDialog(
) {
TabbedDialog(
onDismissRequest = onDismissRequest,
tabTitles = persistentListOf(
tabTitles = listOf(
stringResource(MR.strings.action_filter),
),
) {
@@ -30,7 +30,6 @@ import eu.kanade.presentation.manga.components.MangaBottomActionMenu
import eu.kanade.tachiyomi.data.download.model.Download
import eu.kanade.tachiyomi.ui.updates.UpdatesItem
import eu.kanade.tachiyomi.ui.updates.UpdatesScreenModel
import kotlinx.collections.immutable.persistentListOf
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import tachiyomi.i18n.MR
@@ -156,7 +155,7 @@ private fun UpdatesAppBar(
title = stringResource(MR.strings.label_recent_updates),
actions = {
AppBarActions(
persistentListOf(
listOf(
AppBar.Action(
title = stringResource(MR.strings.action_filter),
icon = Icons.Outlined.FilterList,
@@ -180,7 +179,7 @@ private fun UpdatesAppBar(
onCancelActionMode = onCancelActionMode,
actionModeActions = {
AppBarActions(
persistentListOf(
listOf(
AppBar.Action(
title = stringResource(MR.strings.action_select_all),
icon = Icons.Outlined.SelectAll,
@@ -51,7 +51,6 @@ import eu.kanade.tachiyomi.BuildConfig
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.util.system.getHtml
import eu.kanade.tachiyomi.util.system.setDefaultSettings
import kotlinx.collections.immutable.persistentListOf
import kotlinx.coroutines.launch
import tachiyomi.i18n.MR
import tachiyomi.presentation.core.components.material.Scaffold
@@ -234,7 +233,7 @@ fun WebViewScreenContent(
navigationIcon = Icons.Outlined.Close,
actions = {
AppBarActions(
persistentListOf(
listOf(
AppBar.Action(
title = stringResource(MR.strings.action_webview_back),
icon = Icons.AutoMirrored.Outlined.ArrowBack,
@@ -271,7 +270,7 @@ fun WebViewScreenContent(
title = stringResource(MR.strings.pref_clear_cookies),
onClick = { onClearCookies(currentUrl) },
),
).builder().apply {
).toMutableList().apply {
if (windowStack.size > 1) {
add(
0,
@@ -282,7 +281,7 @@ fun WebViewScreenContent(
),
)
}
}.build(),
},
)
},
)
@@ -1,7 +1,6 @@
package eu.kanade.tachiyomi.data.backup.create
import dev.icerock.moko.resources.StringResource
import kotlinx.collections.immutable.persistentListOf
import tachiyomi.i18n.MR
data class BackupOptions(
@@ -33,7 +32,7 @@ data class BackupOptions(
fun canCreate() = libraryEntries || categories || appSettings || extensionStores || sourceSettings
companion object {
val libraryOptions = persistentListOf(
val libraryOptions = listOf(
Entry(
label = MR.strings.manga,
getter = BackupOptions::libraryEntries,
@@ -70,7 +69,7 @@ data class BackupOptions(
),
)
val settingsOptions = persistentListOf(
val settingsOptions = listOf(
Entry(
label = MR.strings.app_settings,
getter = BackupOptions::appSettings,
@@ -1,7 +1,6 @@
package eu.kanade.tachiyomi.data.backup.restore
import dev.icerock.moko.resources.StringResource
import kotlinx.collections.immutable.persistentListOf
import tachiyomi.i18n.MR
data class RestoreOptions(
@@ -23,7 +22,7 @@ data class RestoreOptions(
fun canRestore() = libraryEntries || categories || appSettings || extensionStores || sourceSettings
companion object {
val options = persistentListOf(
val options = listOf(
Entry(
label = MR.strings.label_library,
getter = RestoreOptions::libraryEntries,
@@ -5,7 +5,6 @@ import androidx.annotation.DrawableRes
import dev.icerock.moko.resources.StringResource
import eu.kanade.tachiyomi.data.database.models.Track
import eu.kanade.tachiyomi.data.track.model.TrackSearch
import kotlinx.collections.immutable.ImmutableList
import kotlinx.coroutines.flow.Flow
import okhttp3.OkHttpClient
import tachiyomi.domain.track.model.Track as DomainTrack
@@ -36,7 +35,7 @@ interface Tracker {
fun getCompletionStatus(): Long
fun getScoreList(): ImmutableList<String>
fun getScoreList(): List<String>
// TODO: Store all scores as 10 point in the future maybe?
fun get10PointScore(track: DomainTrack): Double
@@ -8,9 +8,6 @@ import eu.kanade.tachiyomi.data.track.BaseTracker
import eu.kanade.tachiyomi.data.track.DeletableTracker
import eu.kanade.tachiyomi.data.track.anilist.dto.ALOAuth
import eu.kanade.tachiyomi.data.track.model.TrackSearch
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.persistentListOf
import kotlinx.collections.immutable.toImmutableList
import kotlinx.serialization.json.Json
import tachiyomi.i18n.MR
import uy.kohesive.injekt.injectLazy
@@ -77,18 +74,18 @@ class Anilist(id: Long) : BaseTracker(id, "AniList"), DeletableTracker {
override fun getCompletionStatus(): Long = COMPLETED
override fun getScoreList(): ImmutableList<String> {
override fun getScoreList(): List<String> {
return when (scorePreference.get()) {
// 10 point
POINT_10 -> IntRange(0, 10).map(Int::toString).toImmutableList()
POINT_10 -> IntRange(0, 10).map(Int::toString)
// 100 point
POINT_100 -> IntRange(0, 100).map(Int::toString).toImmutableList()
POINT_100 -> IntRange(0, 100).map(Int::toString)
// 5 stars
POINT_5 -> IntRange(0, 5).map { "$it" }.toImmutableList()
POINT_5 -> IntRange(0, 5).map { "$it" }
// Smiley
POINT_3 -> persistentListOf("-", "😦", "😐", "😊")
POINT_3 -> listOf("-", "😦", "😐", "😊")
// 10 point decimal
POINT_10_DECIMAL -> IntRange(0, 100).map { (it / 10f).toString() }.toImmutableList()
POINT_10_DECIMAL -> IntRange(0, 100).map { (it / 10f).toString() }
else -> throw Exception("Unknown score type")
}
}
@@ -6,8 +6,6 @@ import eu.kanade.tachiyomi.data.database.models.Track
import eu.kanade.tachiyomi.data.track.BaseTracker
import eu.kanade.tachiyomi.data.track.bangumi.dto.BGMOAuth
import eu.kanade.tachiyomi.data.track.model.TrackSearch
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.toImmutableList
import kotlinx.serialization.json.Json
import tachiyomi.i18n.MR
import uy.kohesive.injekt.injectLazy
@@ -23,7 +21,7 @@ class Bangumi(id: Long) : BaseTracker(id, "Bangumi") {
override val supportsPrivateTracking: Boolean = true
override fun getScoreList(): ImmutableList<String> = SCORE_LIST
override fun getScoreList(): List<String> = SCORE_LIST
override fun displayScore(track: DomainTrack): String {
return track.score.toInt().toString()
@@ -142,6 +140,5 @@ class Bangumi(id: Long) : BaseTracker(id, "Bangumi") {
private val SCORE_LIST = IntRange(0, 10)
.map(Int::toString)
.toImmutableList()
}
}
@@ -9,8 +9,6 @@ import eu.kanade.tachiyomi.data.track.model.TrackSearch
import eu.kanade.tachiyomi.source.ConfigurableSource
import eu.kanade.tachiyomi.source.Source
import eu.kanade.tachiyomi.source.sourcePreferences
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.persistentListOf
import tachiyomi.domain.manga.model.Manga
import tachiyomi.domain.source.service.SourceManager
import tachiyomi.i18n.MR
@@ -50,7 +48,7 @@ class Kavita(id: Long) : BaseTracker(id, "Kavita"), EnhancedTracker {
override fun getCompletionStatus(): Long = COMPLETED
override fun getScoreList(): ImmutableList<String> = persistentListOf()
override fun getScoreList(): List<String> = listOf()
override fun displayScore(track: DomainTrack): String = ""
@@ -7,8 +7,6 @@ import eu.kanade.tachiyomi.data.track.BaseTracker
import eu.kanade.tachiyomi.data.track.DeletableTracker
import eu.kanade.tachiyomi.data.track.kitsu.dto.KitsuOAuth
import eu.kanade.tachiyomi.data.track.model.TrackSearch
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.toImmutableList
import kotlinx.serialization.json.Json
import tachiyomi.i18n.MR
import uy.kohesive.injekt.injectLazy
@@ -56,9 +54,9 @@ class Kitsu(id: Long) : BaseTracker(id, "Kitsu"), DeletableTracker {
override fun getCompletionStatus(): Long = COMPLETED
override fun getScoreList(): ImmutableList<String> {
override fun getScoreList(): List<String> {
val df = DecimalFormat("0.#")
return (listOf("0") + IntRange(2, 20).map { df.format(it / 2f) }).toImmutableList()
return (listOf("0") + IntRange(2, 20).map { df.format(it / 2f) })
}
override fun indexToScore(index: Int): Double {
@@ -7,8 +7,6 @@ import eu.kanade.tachiyomi.data.track.BaseTracker
import eu.kanade.tachiyomi.data.track.EnhancedTracker
import eu.kanade.tachiyomi.data.track.model.TrackSearch
import eu.kanade.tachiyomi.source.Source
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.persistentListOf
import okhttp3.Dns
import okhttp3.OkHttpClient
import tachiyomi.domain.manga.model.Manga
@@ -47,7 +45,7 @@ class Komga(id: Long) : BaseTracker(id, "Komga"), EnhancedTracker {
override fun getCompletionStatus(): Long = COMPLETED
override fun getScoreList(): ImmutableList<String> = persistentListOf()
override fun getScoreList(): List<String> = listOf()
override fun displayScore(track: DomainTrack): String = ""
@@ -10,8 +10,6 @@ import eu.kanade.tachiyomi.data.track.mangaupdates.dto.MURating
import eu.kanade.tachiyomi.data.track.mangaupdates.dto.copyTo
import eu.kanade.tachiyomi.data.track.mangaupdates.dto.toTrackSearch
import eu.kanade.tachiyomi.data.track.model.TrackSearch
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.toImmutableList
import tachiyomi.i18n.MR
import tachiyomi.domain.track.model.Track as DomainTrack
@@ -34,7 +32,6 @@ class MangaUpdates(id: Long) : BaseTracker(id, "MangaUpdates"), DeletableTracker
}
}
}
.toImmutableList()
}
private val interceptor by lazy { MangaUpdatesInterceptor(this) }
@@ -62,7 +59,7 @@ class MangaUpdates(id: Long) : BaseTracker(id, "MangaUpdates"), DeletableTracker
override fun getCompletionStatus(): Long = COMPLETE_LIST
override fun getScoreList(): ImmutableList<String> = SCORE_LIST
override fun getScoreList(): List<String> = SCORE_LIST
override fun indexToScore(index: Int): Double = if (index == 0) 0.0 else SCORE_LIST[index].toDouble()
@@ -7,8 +7,6 @@ import eu.kanade.tachiyomi.data.track.BaseTracker
import eu.kanade.tachiyomi.data.track.DeletableTracker
import eu.kanade.tachiyomi.data.track.model.TrackSearch
import eu.kanade.tachiyomi.data.track.myanimelist.dto.MALOAuth
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.toImmutableList
import kotlinx.serialization.json.Json
import tachiyomi.i18n.MR
import uy.kohesive.injekt.injectLazy
@@ -29,7 +27,6 @@ class MyAnimeList(id: Long) : BaseTracker(id, "MyAnimeList"), DeletableTracker {
private val SCORE_LIST = IntRange(0, 10)
.map(Int::toString)
.toImmutableList()
}
private val json: Json by injectLazy()
@@ -61,7 +58,7 @@ class MyAnimeList(id: Long) : BaseTracker(id, "MyAnimeList"), DeletableTracker {
override fun getCompletionStatus(): Long = COMPLETED
override fun getScoreList(): ImmutableList<String> = SCORE_LIST
override fun getScoreList(): List<String> = SCORE_LIST
override fun displayScore(track: DomainTrack): String {
return track.score.toInt().toString()
@@ -7,8 +7,6 @@ import eu.kanade.tachiyomi.data.track.BaseTracker
import eu.kanade.tachiyomi.data.track.DeletableTracker
import eu.kanade.tachiyomi.data.track.model.TrackSearch
import eu.kanade.tachiyomi.data.track.shikimori.dto.SMOAuth
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.toImmutableList
import kotlinx.serialization.json.Json
import tachiyomi.i18n.MR
import uy.kohesive.injekt.injectLazy
@@ -26,7 +24,6 @@ class Shikimori(id: Long) : BaseTracker(id, "Shikimori"), DeletableTracker {
private val SCORE_LIST = IntRange(0, 10)
.map(Int::toString)
.toImmutableList()
}
private val json: Json by injectLazy()
@@ -35,7 +32,7 @@ class Shikimori(id: Long) : BaseTracker(id, "Shikimori"), DeletableTracker {
private val api by lazy { ShikimoriApi(id, client, interceptor) }
override fun getScoreList(): ImmutableList<String> = SCORE_LIST
override fun getScoreList(): List<String> = SCORE_LIST
override fun displayScore(track: DomainTrack): String {
return track.score.toInt().toString()
@@ -7,8 +7,6 @@ import eu.kanade.tachiyomi.data.track.BaseTracker
import eu.kanade.tachiyomi.data.track.EnhancedTracker
import eu.kanade.tachiyomi.data.track.model.TrackSearch
import eu.kanade.tachiyomi.source.Source
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.persistentListOf
import tachiyomi.i18n.MR
import tachiyomi.domain.manga.model.Manga as DomainManga
import tachiyomi.domain.track.model.Track as DomainTrack
@@ -43,7 +41,7 @@ class Suwayomi(id: Long) : BaseTracker(id, "Suwayomi"), EnhancedTracker {
override fun getCompletionStatus(): Long = COMPLETED
override fun getScoreList(): ImmutableList<String> = persistentListOf()
override fun getScoreList(): List<String> = listOf()
override fun displayScore(track: DomainTrack): String = ""
@@ -22,7 +22,6 @@ import eu.kanade.tachiyomi.ui.browse.migration.sources.migrateSourceTab
import eu.kanade.tachiyomi.ui.browse.source.globalsearch.GlobalSearchScreen
import eu.kanade.tachiyomi.ui.browse.source.sourcesTab
import eu.kanade.tachiyomi.ui.main.MainActivity
import kotlinx.collections.immutable.persistentListOf
import kotlinx.coroutines.channels.BufferOverflow
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.flow.collectLatest
@@ -62,7 +61,7 @@ data object BrowseTab : Tab {
val extensionsScreenModel = rememberScreenModel { ExtensionsScreenModel() }
val extensionsState by extensionsScreenModel.state.collectAsState()
val tabs = persistentListOf(
val tabs = listOf(
sourcesTab(),
extensionsTab(extensionsScreenModel),
migrateSourceTab(),
@@ -6,11 +6,6 @@ import cafe.adriel.voyager.core.model.screenModelScope
import eu.kanade.domain.extension.interactor.GetExtensionLanguages
import eu.kanade.domain.source.interactor.ToggleLanguage
import eu.kanade.domain.source.service.SourcePreferences
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.ImmutableSet
import kotlinx.collections.immutable.persistentSetOf
import kotlinx.collections.immutable.toImmutableList
import kotlinx.collections.immutable.toImmutableSet
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.catch
@@ -46,8 +41,8 @@ class ExtensionFilterScreenModel(
.collectLatest { (extensionLanguages, enabledLanguages) ->
mutableState.update {
ExtensionFilterState.Success(
languages = extensionLanguages.toImmutableList(),
enabledLanguages = enabledLanguages.toImmutableSet(),
languages = extensionLanguages,
enabledLanguages = enabledLanguages,
)
}
}
@@ -70,8 +65,8 @@ sealed interface ExtensionFilterState {
@Immutable
data class Success(
val languages: ImmutableList<String>,
val enabledLanguages: ImmutableSet<String> = persistentSetOf(),
val languages: List<String>,
val enabledLanguages: Set<String> = setOf(),
) : ExtensionFilterState {
val isEmpty: Boolean
@@ -21,7 +21,6 @@ import eu.kanade.tachiyomi.extension.model.Extension
import eu.kanade.tachiyomi.ui.browse.extension.details.ExtensionDetailsScreen
import eu.kanade.tachiyomi.ui.webview.WebViewScreen
import eu.kanade.tachiyomi.util.system.isPackageInstalled
import kotlinx.collections.immutable.persistentListOf
import tachiyomi.i18n.MR
import tachiyomi.presentation.core.i18n.stringResource
@@ -39,7 +38,7 @@ fun extensionsTab(
titleRes = MR.strings.label_extensions,
badgeNumber = state.updates.takeIf { it > 0 },
searchEnabled = true,
actions = persistentListOf(
actions = listOf(
AppBar.OverflowAction(
title = stringResource(MR.strings.action_filter),
onClick = { navigator.push(ExtensionFilterScreen()) },
@@ -14,9 +14,6 @@ import eu.kanade.tachiyomi.extension.model.Extension
import eu.kanade.tachiyomi.network.NetworkHelper
import eu.kanade.tachiyomi.source.online.HttpSource
import eu.kanade.tachiyomi.util.system.LocaleHelper
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.persistentListOf
import kotlinx.collections.immutable.toImmutableList
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.catch
@@ -78,10 +75,10 @@ class ExtensionDetailsScreenModel(
}
.catch { throwable ->
logcat(LogPriority.ERROR, throwable)
mutableState.update { it.copy(_sources = persistentListOf()) }
mutableState.update { it.copy(_sources = listOf()) }
}
.collectLatest { sources ->
mutableState.update { it.copy(_sources = sources.toImmutableList()) }
mutableState.update { it.copy(_sources = sources) }
}
}
}
@@ -142,11 +139,11 @@ class ExtensionDetailsScreenModel(
data class State(
val extension: Extension.Installed? = null,
val isIncognito: Boolean = false,
private val _sources: ImmutableList<ExtensionSourceItem>? = null,
private val _sources: List<ExtensionSourceItem>? = null,
) {
val sources: ImmutableList<ExtensionSourceItem>
get() = _sources ?: persistentListOf()
val sources: List<ExtensionSourceItem>
get() = _sources ?: listOf()
val isLoading: Boolean
get() = extension == null || _sources == null
@@ -4,9 +4,6 @@ import androidx.compose.runtime.Immutable
import cafe.adriel.voyager.core.model.StateScreenModel
import cafe.adriel.voyager.core.model.screenModelScope
import eu.kanade.tachiyomi.source.Source
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.persistentListOf
import kotlinx.collections.immutable.toImmutableList
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.catch
@@ -44,13 +41,12 @@ class MigrateMangaScreenModel(
logcat(LogPriority.ERROR, it)
_events.send(MigrationMangaEvent.FailedFetchingFavorites)
mutableState.update { state ->
state.copy(titleList = persistentListOf())
state.copy(titleList = listOf())
}
}
.map { manga ->
manga
.sortedWith(compareBy(String.CASE_INSENSITIVE_ORDER) { it.title })
.toImmutableList()
}
.collectLatest { list ->
mutableState.update { it.copy(titleList = list) }
@@ -75,11 +71,11 @@ class MigrateMangaScreenModel(
data class State(
val source: Source? = null,
val selection: Set<Long> = emptySet(),
private val titleList: ImmutableList<Manga>? = null,
private val titleList: List<Manga>? = null,
) {
val titles: ImmutableList<Manga>
get() = titleList ?: persistentListOf()
val titles: List<Manga>
get() = titleList ?: listOf()
val isLoading: Boolean
get() = source == null || titleList == null
@@ -6,9 +6,6 @@ import cafe.adriel.voyager.core.model.screenModelScope
import eu.kanade.domain.source.interactor.GetSourcesWithFavoriteCount
import eu.kanade.domain.source.interactor.SetMigrateSorting
import eu.kanade.domain.source.service.SourcePreferences
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.persistentListOf
import kotlinx.collections.immutable.toImmutableList
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.collectLatest
@@ -43,7 +40,7 @@ class MigrateSourceScreenModel(
mutableState.update {
it.copy(
isLoading = false,
items = sources.toImmutableList(),
items = sources,
)
}
}
@@ -83,7 +80,7 @@ class MigrateSourceScreenModel(
@Immutable
data class State(
val isLoading: Boolean = true,
val items: ImmutableList<Pair<Source, Long>> = persistentListOf(),
val items: List<Pair<Source, Long>> = listOf(),
val sortingMode: SetMigrateSorting.Mode = SetMigrateSorting.Mode.ALPHABETICAL,
val sortingDirection: SetMigrateSorting.Direction = SetMigrateSorting.Direction.ASCENDING,
) {
@@ -14,7 +14,6 @@ import eu.kanade.presentation.browse.MigrateSourceScreen
import eu.kanade.presentation.components.AppBar
import eu.kanade.presentation.components.TabContent
import eu.kanade.tachiyomi.ui.browse.migration.manga.MigrateMangaScreen
import kotlinx.collections.immutable.persistentListOf
import tachiyomi.i18n.MR
import tachiyomi.presentation.core.i18n.stringResource
@@ -27,7 +26,7 @@ fun Screen.migrateSourceTab(): TabContent {
return TabContent(
titleRes = MR.strings.label_migration,
actions = persistentListOf(
actions = listOf(
AppBar.Action(
title = stringResource(MR.strings.migration_help_guide),
icon = Icons.AutoMirrored.Outlined.HelpOutline,
@@ -7,9 +7,6 @@ import eu.kanade.domain.source.interactor.GetEnabledSources
import eu.kanade.domain.source.interactor.ToggleSource
import eu.kanade.domain.source.interactor.ToggleSourcePin
import eu.kanade.presentation.browse.SourceUiModel
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.persistentListOf
import kotlinx.collections.immutable.toImmutableList
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.collectLatest
@@ -76,8 +73,7 @@ class SourcesScreenModel(
SourceUiModel.Item(source)
}.toTypedArray(),
)
}
.toImmutableList(),
},
)
}
}
@@ -108,7 +104,7 @@ class SourcesScreenModel(
data class State(
val dialog: Dialog? = null,
val isLoading: Boolean = true,
val items: ImmutableList<SourceUiModel> = persistentListOf(),
val items: List<SourceUiModel> = listOf(),
) {
val isEmpty = items.isEmpty()
}
@@ -17,7 +17,6 @@ import eu.kanade.presentation.components.AppBar
import eu.kanade.presentation.components.TabContent
import eu.kanade.tachiyomi.ui.browse.source.browse.BrowseSourceScreen
import eu.kanade.tachiyomi.ui.browse.source.globalsearch.GlobalSearchScreen
import kotlinx.collections.immutable.persistentListOf
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.launch
import tachiyomi.i18n.MR
@@ -31,7 +30,7 @@ fun Screen.sourcesTab(): TabContent {
return TabContent(
titleRes = MR.strings.label_sources,
actions = persistentListOf(
actions = listOf(
AppBar.Action(
title = stringResource(MR.strings.action_global_search),
icon = Icons.Outlined.TravelExplore,
@@ -23,8 +23,6 @@ import eu.kanade.tachiyomi.data.cache.CoverCache
import eu.kanade.tachiyomi.source.CatalogueSource
import eu.kanade.tachiyomi.source.model.FilterList
import eu.kanade.tachiyomi.util.removeCovers
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.toImmutableList
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.emptyFlow
@@ -265,7 +263,7 @@ class BrowseSourceScreenModel(
setDialog(
Dialog.ChangeMangaCategory(
manga,
categories.mapAsCheckboxState { it.id in preselectedIds }.toImmutableList(),
categories.mapAsCheckboxState { it.id in preselectedIds },
),
)
}
@@ -339,7 +337,7 @@ class BrowseSourceScreenModel(
data class AddDuplicateManga(val manga: Manga, val duplicates: List<MangaWithChapterCount>) : Dialog
data class ChangeMangaCategory(
val manga: Manga,
val initialSelection: ImmutableList<CheckboxState.State<Category>>,
val initialSelection: List<CheckboxState.State<Category>>,
) : Dialog
data class Migrate(val target: Manga, val current: Manga) : Dialog
}
@@ -9,10 +9,6 @@ import eu.kanade.domain.source.service.SourcePreferences
import eu.kanade.presentation.util.ioCoroutineScope
import eu.kanade.tachiyomi.extension.ExtensionManager
import eu.kanade.tachiyomi.source.CatalogueSource
import kotlinx.collections.immutable.PersistentMap
import kotlinx.collections.immutable.mutate
import kotlinx.collections.immutable.persistentMapOf
import kotlinx.collections.immutable.toPersistentMap
import kotlinx.coroutines.Job
import kotlinx.coroutines.asCoroutineDispatcher
import kotlinx.coroutines.async
@@ -143,14 +139,12 @@ abstract class SearchScreenModel(
val existingResults = state.value.items
updateItems(
sources
.associateWith { existingResults[it] ?: SearchItemResult.Loading }
.toPersistentMap(),
.associateWith { existingResults[it] ?: SearchItemResult.Loading },
)
} else {
updateItems(
sources
.associateWith { SearchItemResult.Loading }
.toPersistentMap(),
.associateWith { SearchItemResult.Loading },
)
}
@@ -185,21 +179,17 @@ abstract class SearchScreenModel(
}
}
private fun updateItems(items: PersistentMap<CatalogueSource, SearchItemResult>) {
private fun updateItems(items: Map<CatalogueSource, SearchItemResult>) {
mutableState.update {
it.copy(
items = items
.toSortedMap(sortComparator(items))
.toPersistentMap(),
.toSortedMap(sortComparator(items)),
)
}
}
private fun updateItem(source: CatalogueSource, result: SearchItemResult) {
val newItems = state.value.items.mutate {
it[source] = result
}
updateItems(newItems)
updateItems(state.value.items + (source to result))
}
fun setMigrateDialog(currentId: Long, target: Manga) {
@@ -219,7 +209,7 @@ abstract class SearchScreenModel(
val searchQuery: String? = null,
val sourceFilter: SourceFilter = SourceFilter.PinnedOnly,
val onlyShowHasResults: Boolean = false,
val items: PersistentMap<CatalogueSource, SearchItemResult> = persistentMapOf(),
val items: Map<CatalogueSource, SearchItemResult> = mapOf(),
val dialog: Dialog? = null,
) {
val progress: Int = items.count { it.value !is SearchItemResult.Loading }
@@ -15,7 +15,6 @@ import eu.kanade.presentation.category.components.CategoryDeleteDialog
import eu.kanade.presentation.category.components.CategoryRenameDialog
import eu.kanade.presentation.util.Screen
import eu.kanade.tachiyomi.util.system.toast
import kotlinx.collections.immutable.toImmutableList
import kotlinx.coroutines.flow.collectLatest
import tachiyomi.presentation.core.screens.LoadingScreen
@@ -51,14 +50,14 @@ class CategoryScreen : Screen() {
CategoryCreateDialog(
onDismissRequest = screenModel::dismissDialog,
onCreate = screenModel::createCategory,
categories = successState.categories.fastMap { it.name }.toImmutableList(),
categories = successState.categories.fastMap { it.name },
)
}
is CategoryDialog.Rename -> {
CategoryRenameDialog(
onDismissRequest = screenModel::dismissDialog,
onRename = { screenModel.renameCategory(dialog.category, it) },
categories = successState.categories.fastMap { it.name }.toImmutableList(),
categories = successState.categories.fastMap { it.name },
category = dialog.category.name,
)
}
@@ -4,8 +4,6 @@ import androidx.compose.runtime.Immutable
import cafe.adriel.voyager.core.model.StateScreenModel
import cafe.adriel.voyager.core.model.screenModelScope
import dev.icerock.moko.resources.StringResource
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.toImmutableList
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.receiveAsFlow
@@ -39,8 +37,7 @@ class CategoryScreenModel(
mutableState.update {
CategoryScreenState.Success(
categories = categories
.filterNot(Category::isSystemCategory)
.toImmutableList(),
.filterNot(Category::isSystemCategory),
)
}
}
@@ -120,7 +117,7 @@ sealed interface CategoryScreenState {
@Immutable
data class Success(
val categories: ImmutableList<Category>,
val categories: List<Category>,
val dialog: CategoryDialog? = null,
) : CategoryScreenState {
@@ -51,7 +51,6 @@ import eu.kanade.presentation.components.DropdownMenu
import eu.kanade.presentation.components.NestedMenuItem
import eu.kanade.presentation.util.Screen
import eu.kanade.tachiyomi.databinding.DownloadListBinding
import kotlinx.collections.immutable.persistentListOf
import tachiyomi.core.common.util.lang.launchUI
import tachiyomi.i18n.MR
import tachiyomi.presentation.core.components.Pill
@@ -181,7 +180,7 @@ object DownloadQueueScreen : Screen() {
}
AppBarActions(
persistentListOf(
listOf(
AppBar.Action(
title = stringResource(MR.strings.action_sort),
icon = Icons.AutoMirrored.Outlined.Sort,
@@ -9,8 +9,6 @@ import eu.kanade.domain.manga.interactor.UpdateManga
import eu.kanade.domain.track.interactor.AddTracks
import eu.kanade.presentation.history.HistoryUiModel
import eu.kanade.tachiyomi.util.lang.toLocalDate
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.toImmutableList
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.flow.Flow
@@ -230,7 +228,7 @@ class HistoryScreenModel(
currentState.copy(
dialog = Dialog.ChangeCategory(
manga = manga,
initialSelection = categories.mapAsCheckboxState { it.id in selection }.toImmutableList(),
initialSelection = categories.mapAsCheckboxState { it.id in selection },
),
)
}
@@ -250,7 +248,7 @@ class HistoryScreenModel(
data class DuplicateManga(val manga: Manga, val duplicates: List<MangaWithChapterCount>) : Dialog
data class ChangeCategory(
val manga: Manga,
val initialSelection: ImmutableList<CheckboxState<Category>>,
val initialSelection: List<CheckboxState<Category>>,
) : Dialog
data class Migrate(val target: Manga, val current: Manga) : Dialog
}
@@ -23,8 +23,6 @@ import eu.kanade.tachiyomi.source.model.SManga
import eu.kanade.tachiyomi.source.online.HttpSource
import eu.kanade.tachiyomi.util.chapter.getNextUnread
import eu.kanade.tachiyomi.util.removeCovers
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.toImmutableList
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.combine
@@ -709,7 +707,7 @@ class LibraryScreenModel(
else -> CheckboxState.State.None(it)
}
}
.toImmutableList()
mutableState.update { it.copy(dialog = Dialog.ChangeCategory(mangaList, preselected)) }
}
}
@@ -726,7 +724,7 @@ class LibraryScreenModel(
data object SettingsSheet : Dialog
data class ChangeCategory(
val manga: List<Manga>,
val initialSelection: ImmutableList<CheckboxState<Category>>,
val initialSelection: List<CheckboxState<Category>>,
) : Dialog
data class DeleteManga(val manga: List<Manga>) : Dialog
}
@@ -43,7 +43,6 @@ import eu.kanade.tachiyomi.ui.home.HomeScreen
import eu.kanade.tachiyomi.ui.main.MainActivity
import eu.kanade.tachiyomi.ui.manga.MangaScreen
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
import kotlinx.collections.immutable.persistentListOf
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.receiveAsFlow
@@ -168,7 +167,7 @@ data object LibraryTab : Tab {
EmptyScreen(
stringRes = MR.strings.information_empty_library,
modifier = Modifier.padding(contentPadding),
actions = persistentListOf(
actions = listOf(
EmptyScreenAction(
stringRes = MR.strings.getting_started_guide,
icon = Icons.AutoMirrored.Outlined.HelpOutline,
@@ -42,8 +42,6 @@ import eu.kanade.tachiyomi.ui.reader.setting.ReaderPreferences
import eu.kanade.tachiyomi.util.chapter.getNextUnread
import eu.kanade.tachiyomi.util.removeCovers
import eu.kanade.tachiyomi.util.system.toast
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.toImmutableList
import kotlinx.coroutines.async
import kotlinx.coroutines.awaitAll
import kotlinx.coroutines.flow.catch
@@ -374,7 +372,7 @@ class MangaScreenModel(
successState.copy(
dialog = Dialog.ChangeCategory(
manga = manga,
initialSelection = categories.mapAsCheckboxState { it.id in selection }.toImmutableList(),
initialSelection = categories.mapAsCheckboxState { it.id in selection },
),
)
}
@@ -1081,7 +1079,7 @@ class MangaScreenModel(
sealed interface Dialog {
data class ChangeCategory(
val manga: Manga,
val initialSelection: ImmutableList<CheckboxState<Category>>,
val initialSelection: List<CheckboxState<Category>>,
) : Dialog
data class DeleteChapters(val chapters: List<Chapter>) : Dialog
data class DuplicateManga(val manga: Manga, val duplicates: List<MangaWithChapterCount>) : Dialog
@@ -58,7 +58,6 @@ import eu.kanade.tachiyomi.util.lang.toLocalDate
import eu.kanade.tachiyomi.util.system.copyToClipboard
import eu.kanade.tachiyomi.util.system.openInBrowser
import eu.kanade.tachiyomi.util.system.toast
import kotlinx.collections.immutable.ImmutableList
import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.distinctUntilChanged
@@ -416,7 +415,7 @@ private data class TrackScoreSelectorScreen(
private val tracker: Tracker,
) : StateScreenModel<Model.State>(State(tracker.displayScore(track))) {
fun getSelections(): ImmutableList<String> {
fun getSelections(): List<String> {
return tracker.getScoreList()
}
@@ -18,10 +18,6 @@ import eu.kanade.tachiyomi.data.download.DownloadManager
import eu.kanade.tachiyomi.data.download.model.Download
import eu.kanade.tachiyomi.data.library.LibraryUpdateJob
import eu.kanade.tachiyomi.util.lang.toLocalDate
import kotlinx.collections.immutable.PersistentList
import kotlinx.collections.immutable.mutate
import kotlinx.collections.immutable.persistentListOf
import kotlinx.collections.immutable.toPersistentList
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.catch
@@ -106,7 +102,6 @@ class UpdatesScreenModel(
updates
.toUpdateItems()
.applyFilters(itemPreferences)
.toPersistentList()
}
.collectLatest { updateItems ->
mutableState.update {
@@ -199,9 +194,9 @@ class UpdatesScreenModel(
*/
private fun updateDownloadState(download: Download) {
mutableState.update { state ->
val newItems = state.items.mutate { list ->
val newItems = state.items.toMutableList().also { list ->
val modifiedIndex = list.indexOfFirst { it.update.chapterId == download.chapter.id }
if (modifiedIndex < 0) return@mutate
if (modifiedIndex < 0) return@also
val item = list[modifiedIndex]
list[modifiedIndex] = item.copy(
@@ -381,7 +376,7 @@ class UpdatesScreenModel(
}
}
}
state.copy(items = newItems.toPersistentList())
state.copy(items = newItems)
}
}
@@ -391,7 +386,7 @@ class UpdatesScreenModel(
selectedChapterIds.addOrRemove(it.update.chapterId, selected)
it.copy(selected = selected)
}
state.copy(items = newItems.toPersistentList())
state.copy(items = newItems)
}
selectedPositions[0] = -1
@@ -404,7 +399,7 @@ class UpdatesScreenModel(
selectedChapterIds.addOrRemove(it.update.chapterId, !it.selected)
it.copy(selected = !it.selected)
}
state.copy(items = newItems.toPersistentList())
state.copy(items = newItems)
}
selectedPositions[0] = -1
selectedPositions[1] = -1
@@ -453,7 +448,7 @@ class UpdatesScreenModel(
data class State(
val isLoading: Boolean = true,
val hasActiveFilters: Boolean = false,
val items: PersistentList<UpdatesItem> = persistentListOf(),
val items: List<UpdatesItem> = listOf(),
val dialog: Dialog? = null,
) {
val selected = items.filter { it.selected }
@@ -4,8 +4,6 @@ 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.TrackSearch
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.toImmutableList
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flowOf
import okhttp3.OkHttpClient
@@ -24,7 +22,7 @@ data class DummyTracker(
val valReadingStatus: Long = 1L,
val valRereadingStatus: Long = 1L,
val valCompletionStatus: Long = 2L,
val valScoreList: ImmutableList<String> = (0..10).map(Int::toString).toImmutableList(),
val valScoreList: List<String> = (0..10).map(Int::toString),
val val10PointScore: Double = 5.4,
val valSearchResults: List<TrackSearch> = listOf(),
) : Tracker {
@@ -52,7 +50,7 @@ data class DummyTracker(
override fun getCompletionStatus(): Long = valCompletionStatus
override fun getScoreList(): ImmutableList<String> = valScoreList
override fun getScoreList(): List<String> = valScoreList
override fun get10PointScore(track: Track): Double = val10PointScore
@@ -49,7 +49,6 @@ import eu.kanade.presentation.util.Screen
import eu.kanade.tachiyomi.source.online.HttpSource
import eu.kanade.tachiyomi.ui.browse.migration.search.MigrateSearchScreen
import eu.kanade.tachiyomi.util.system.LocaleHelper
import kotlinx.collections.immutable.persistentListOf
import kotlinx.coroutines.flow.update
import mihon.feature.migration.list.MigrationListScreen
import sh.calvin.reorderable.ReorderableCollectionItemScope
@@ -118,7 +117,7 @@ class MigrationConfigScreen(private val mangaIds: Collection<Long>) : Screen() {
scrollBehavior = it,
actions = {
AppBarActions(
persistentListOf(
listOf(
AppBar.Action(
title = stringResource(MR.strings.migrationConfigScreen_selectAllLabel),
icon = Icons.Outlined.SelectAll,
@@ -55,8 +55,6 @@ import eu.kanade.presentation.util.animateItemFastScroll
import eu.kanade.presentation.util.formatChapterNumber
import eu.kanade.presentation.util.rememberResourceBitmapPainter
import eu.kanade.tachiyomi.R
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.persistentListOf
import mihon.feature.migration.list.models.MigratingManga
import tachiyomi.domain.manga.model.Manga
import tachiyomi.i18n.MR
@@ -71,7 +69,7 @@ import tachiyomi.presentation.core.util.plus
@Composable
fun MigrationListScreenContent(
items: ImmutableList<MigratingManga>,
items: List<MigratingManga>,
migrationComplete: Boolean,
finishedCount: Int,
onItemClick: (Manga) -> Unit,
@@ -91,7 +89,7 @@ fun MigrationListScreenContent(
},
actions = {
AppBarActions(
persistentListOf(
listOf(
AppBar.Action(
title = stringResource(MR.strings.migrationListScreen_copyActionLabel),
icon = if (items.size == 1) Icons.Outlined.ContentCopy else Icons.Outlined.CopyAll,
@@ -9,10 +9,6 @@ import eu.kanade.domain.manga.model.toSManga
import eu.kanade.domain.source.service.SourcePreferences
import eu.kanade.tachiyomi.source.CatalogueSource
import eu.kanade.tachiyomi.source.getNameForMangaInfo
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.persistentListOf
import kotlinx.collections.immutable.toImmutableList
import kotlinx.collections.immutable.toPersistentList
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.Job
import kotlinx.coroutines.async
@@ -86,7 +82,7 @@ class MigrationListScreenModel(
}
.awaitAll()
.filterNotNull()
mutableState.update { it.copy(items = manga.toImmutableList()) }
mutableState.update { it.copy(items = manga) }
runMigrations(manga)
}
}
@@ -327,7 +323,7 @@ class MigrationListScreenModel(
}
private fun removeManga(item: MigratingManga) {
mutableState.update { it.copy(items = items.toPersistentList().remove(item)) }
mutableState.update { it.copy(items = items.toMutableList().apply { remove(item) }) }
}
override fun onDispose() {
@@ -371,7 +367,7 @@ class MigrationListScreenModel(
}
data class State(
val items: ImmutableList<MigratingManga> = persistentListOf(),
val items: List<MigratingManga> = listOf(),
val finishedCount: Int = 0,
val migrationComplete: Boolean = false,
val dialog: Dialog? = null,
@@ -25,8 +25,6 @@ import cafe.adriel.voyager.navigator.currentOrThrow
import eu.kanade.presentation.components.AppBar
import eu.kanade.presentation.components.relativeDateText
import eu.kanade.presentation.util.isTabletUi
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.ImmutableMap
import kotlinx.coroutines.launch
import mihon.feature.upcoming.components.UpcomingItem
import mihon.feature.upcoming.components.calendar.Calendar
@@ -136,8 +134,8 @@ private fun DateHeading(
@Composable
private fun UpcomingScreenSmallImpl(
listState: LazyListState,
items: ImmutableList<UpcomingUIModel>,
events: ImmutableMap<LocalDate, Int>,
items: List<UpcomingUIModel>,
events: Map<LocalDate, Int>,
paddingValues: PaddingValues,
selectedYearMonth: YearMonth,
setSelectedYearMonth: (YearMonth) -> Unit,
@@ -187,8 +185,8 @@ private fun UpcomingScreenSmallImpl(
@Composable
private fun UpcomingScreenLargeImpl(
listState: LazyListState,
items: ImmutableList<UpcomingUIModel>,
events: ImmutableMap<LocalDate, Int>,
items: List<UpcomingUIModel>,
events: Map<LocalDate, Int>,
paddingValues: PaddingValues,
selectedYearMonth: YearMonth,
setSelectedYearMonth: (YearMonth) -> Unit,
@@ -6,12 +6,6 @@ import cafe.adriel.voyager.core.model.StateScreenModel
import cafe.adriel.voyager.core.model.screenModelScope
import eu.kanade.core.util.insertSeparatorsReversed
import eu.kanade.tachiyomi.util.lang.toLocalDate
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.ImmutableMap
import kotlinx.collections.immutable.persistentListOf
import kotlinx.collections.immutable.persistentMapOf
import kotlinx.collections.immutable.toImmutableList
import kotlinx.collections.immutable.toImmutableMap
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.update
import kotlinx.coroutines.launch
@@ -41,7 +35,7 @@ class UpcomingScreenModel(
}
}
private fun List<Manga>.toUpcomingUIModels(): ImmutableList<UpcomingUIModel> {
private fun List<Manga>.toUpcomingUIModels(): List<UpcomingUIModel> {
var mangaCount = 0
return fastMap { UpcomingUIModel.Item(it) }
.insertSeparatorsReversed { before, after ->
@@ -56,16 +50,14 @@ class UpcomingScreenModel(
null
}
}
.toImmutableList()
}
private fun List<UpcomingUIModel>.toEvents(): ImmutableMap<LocalDate, Int> {
private fun List<UpcomingUIModel>.toEvents(): Map<LocalDate, Int> {
return filterIsInstance<UpcomingUIModel.Header>()
.associate { it.date to it.mangaCount }
.toImmutableMap()
}
private fun List<UpcomingUIModel>.getHeaderIndexes(): ImmutableMap<LocalDate, Int> {
private fun List<UpcomingUIModel>.getHeaderIndexes(): Map<LocalDate, Int> {
return fastMapIndexedNotNull { index, upcomingUIModel ->
if (upcomingUIModel is UpcomingUIModel.Header) {
upcomingUIModel.date to index
@@ -74,7 +66,6 @@ class UpcomingScreenModel(
}
}
.toMap()
.toImmutableMap()
}
fun setSelectedYearMonth(yearMonth: YearMonth) {
@@ -83,8 +74,8 @@ class UpcomingScreenModel(
data class State(
val selectedYearMonth: YearMonth = YearMonth.now(),
val items: ImmutableList<UpcomingUIModel> = persistentListOf(),
val events: ImmutableMap<LocalDate, Int> = persistentMapOf(),
val headerIndexes: ImmutableMap<LocalDate, Int> = persistentMapOf(),
val items: List<UpcomingUIModel> = listOf(),
val events: Map<LocalDate, Int> = mapOf(),
val headerIndexes: Map<LocalDate, Int> = mapOf(),
)
}
@@ -19,8 +19,6 @@ import androidx.compose.ui.unit.sp
import androidx.compose.ui.util.fastForEach
import io.woong.compose.grid.SimpleGridCells
import io.woong.compose.grid.VerticalGrid
import kotlinx.collections.immutable.ImmutableMap
import kotlinx.collections.immutable.toImmutableList
import mihon.core.designsystem.utils.isExpandedWidthWindow
import mihon.core.designsystem.utils.isMediumWidthWindow
import tachiyomi.presentation.core.components.material.padding
@@ -37,7 +35,7 @@ private const val DAYS_OF_WEEK = 7
@Composable
fun Calendar(
selectedYearMonth: YearMonth,
events: ImmutableMap<LocalDate, Int>,
events: Map<LocalDate, Int>,
setSelectedYearMonth: (YearMonth) -> Unit,
onClickDay: (day: LocalDate) -> Unit,
modifier: Modifier = Modifier,
@@ -67,14 +65,13 @@ fun Calendar(
@Composable
private fun CalendarGrid(
selectedYearMonth: YearMonth,
events: ImmutableMap<LocalDate, Int>,
events: Map<LocalDate, Int>,
onClickDay: (day: LocalDate) -> Unit,
) {
val localeFirstDayOfWeek = WeekFields.of(Locale.getDefault()).firstDayOfWeek.value
val weekDays = remember {
(0 until DAYS_OF_WEEK)
.map { DayOfWeek.of((localeFirstDayOfWeek - 1 + it) % DAYS_OF_WEEK + 1) }
.toImmutableList()
}
val emptyFieldCount = weekDays.indexOf(selectedYearMonth.atDay(1).dayOfWeek)