diff --git a/app/src/main/java/mihon/feature/migration/config/MigrationConfigScreenSheet.kt b/app/src/main/java/mihon/feature/migration/config/MigrationConfigScreenSheet.kt index e9288142b..20d97b0e8 100644 --- a/app/src/main/java/mihon/feature/migration/config/MigrationConfigScreenSheet.kt +++ b/app/src/main/java/mihon/feature/migration/config/MigrationConfigScreenSheet.kt @@ -29,6 +29,8 @@ import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color +import androidx.compose.ui.util.fastForEach +import eu.kanade.core.util.fastFilterNot import eu.kanade.domain.source.service.SourcePreferences import eu.kanade.presentation.components.AdaptiveSheet import mihon.domain.migration.models.MigrationFlag @@ -77,31 +79,32 @@ fun MigrationConfigScreenSheet( .padding(bottom = MaterialTheme.padding.extraSmall), horizontalArrangement = Arrangement.spacedBy(MaterialTheme.padding.small), ) { - MigrationFlag.entries.forEach { flag -> - if (flag == MigrationFlag.REMOVE_DOWNLOAD) return@forEach - val selected = flag in migrationFlags - FilterChip( - selected = selected, - onClick = { - preferences.migrationFlags().getAndSet { - if (selected) { - it - flag - } else { - it + flag + MigrationFlag.entries + .fastFilterNot { it == MigrationFlag.REMOVE_DOWNLOAD } + .fastForEach { flag -> + val selected = flag in migrationFlags + FilterChip( + selected = selected, + onClick = { + preferences.migrationFlags().getAndSet { currentFlags -> + if (flag in currentFlags) { + currentFlags - flag + } else { + currentFlags + flag + } } - } - }, - label = { Text(stringResource(flag.getLabel())) }, - leadingIcon = { - if (selected) { - Icon( - imageVector = Icons.Outlined.Check, - contentDescription = null, - ) - } - }, - ) - } + }, + label = { Text(stringResource(flag.getLabel())) }, + leadingIcon = { + if (selected) { + Icon( + imageVector = Icons.Outlined.Check, + contentDescription = null, + ) + } + }, + ) + } } val removeDownloads = MigrationFlag.REMOVE_DOWNLOAD in migrationFlags MigrationSheetSwitchItem( @@ -123,9 +126,6 @@ fun MigrationConfigScreenSheet( value = extraSearchQuery, onValueChange = { extraSearchQuery = it }, label = { Text(stringResource(MR.strings.migrationConfigScreen_additionalSearchQueryLabel)) }, - placeholder = { - Text(stringResource(MR.strings.migrationConfigScreen_additionalSearchQueryPlaceholder)) - }, supportingText = { Text(stringResource(MR.strings.migrationConfigScreen_additionalSearchQuerySupportingText)) }, @@ -142,13 +142,13 @@ fun MigrationConfigScreenSheet( subtitle = null, preference = preferences.migrationHideUnmatched(), ) - MigrationSheetDividerItem() - MigrationSheetWarningItem(stringResource(MR.strings.migrationConfigScreen_enhancedOptionsWarning)) MigrationSheetSwitchItem( title = stringResource(MR.strings.migrationConfigScreen_hideWithoutUpdatesTitle), subtitle = stringResource(MR.strings.migrationConfigScreen_hideWithoutUpdatesSubtitle), preference = preferences.migrationHideWithoutUpdates(), ) + MigrationSheetDividerItem() + MigrationSheetWarningItem(stringResource(MR.strings.migrationConfigScreen_enhancedOptionsWarning)) MigrationSheetSwitchItem( title = stringResource(MR.strings.migrationConfigScreen_deepSearchModeTitle), subtitle = stringResource(MR.strings.migrationConfigScreen_deepSearchModeSubtitle), @@ -156,13 +156,16 @@ fun MigrationConfigScreenSheet( ) MigrationSheetSwitchItem( title = stringResource(MR.strings.migrationConfigScreen_prioritizeByChaptersTitle), - subtitle = null, + subtitle = stringResource(MR.strings.migrationConfigScreen_prioritizeByChaptersSubtitle), preference = preferences.migrationPrioritizeByChapters(), ) } HorizontalDivider() Button( - onClick = { onStartMigration(extraSearchQuery) }, + onClick = { + val cleanedExtraSearchQuery = extraSearchQuery.trim().ifBlank { null } + onStartMigration(cleanedExtraSearchQuery) + }, modifier = Modifier .fillMaxWidth() .padding( @@ -182,11 +185,10 @@ private fun MigrationSheetSwitchItem( subtitle: String?, preference: Preference, ) { - val checked by preference.collectAsState() MigrationSheetSwitchItem( title = title, subtitle = subtitle, - checked = checked, + checked = preference.collectAsState().value, onClick = { preference.toggle() }, ) } diff --git a/i18n/src/commonMain/moko-resources/base/strings.xml b/i18n/src/commonMain/moko-resources/base/strings.xml index 484611076..9105e64de 100644 --- a/i18n/src/commonMain/moko-resources/base/strings.xml +++ b/i18n/src/commonMain/moko-resources/base/strings.xml @@ -1005,15 +1005,15 @@ Select pinned sources Continue Data to migrate - Delete downloads after migration - Additional search keywords - e.g. language:english - Appends keywords to the search query - Hide unmatched manga - Settings below can be slower and may lead to temporary source restrictions - Hide if no new chapters - Show only if the match offers newer chapters - Deep search mode - More detailed keyword search - Prioritize by newer chapters + Delete downloads of current entry after migration + Additional keywords (optional) + Helps narrow down search results by adding additional keywords + Hide entries without a match + Hide entries without newer chapters + Only show entry if the match has additional chapters + These options are slow and dangerous and may lead to restrictions from sources + Advanced search mode + Breaks down the title into keywords for a wider search + Match based on chapter number + If enabled, chooses the match furthest ahead. Otherwise, picks the first match by source priority.