|
@@ -1,33 +1,18 @@
|
|
|
package eu.kanade.presentation.more.settings.screen
|
|
|
|
|
|
import androidx.annotation.StringRes
|
|
|
-import androidx.compose.foundation.layout.Arrangement
|
|
|
-import androidx.compose.foundation.layout.BoxWithConstraints
|
|
|
-import androidx.compose.foundation.layout.Column
|
|
|
-import androidx.compose.foundation.layout.Row
|
|
|
-import androidx.compose.foundation.layout.fillMaxWidth
|
|
|
-import androidx.compose.material3.AlertDialog
|
|
|
-import androidx.compose.material3.MaterialTheme
|
|
|
-import androidx.compose.material3.Text
|
|
|
-import androidx.compose.material3.TextButton
|
|
|
import androidx.compose.runtime.Composable
|
|
|
import androidx.compose.runtime.ReadOnlyComposable
|
|
|
import androidx.compose.runtime.collectAsState
|
|
|
import androidx.compose.runtime.getValue
|
|
|
-import androidx.compose.runtime.mutableIntStateOf
|
|
|
import androidx.compose.runtime.mutableStateOf
|
|
|
import androidx.compose.runtime.remember
|
|
|
import androidx.compose.runtime.rememberCoroutineScope
|
|
|
import androidx.compose.runtime.saveable.rememberSaveable
|
|
|
import androidx.compose.runtime.setValue
|
|
|
-import androidx.compose.ui.Alignment
|
|
|
-import androidx.compose.ui.Modifier
|
|
|
import androidx.compose.ui.platform.LocalContext
|
|
|
import androidx.compose.ui.res.pluralStringResource
|
|
|
import androidx.compose.ui.res.stringResource
|
|
|
-import androidx.compose.ui.text.style.TextAlign
|
|
|
-import androidx.compose.ui.unit.DpSize
|
|
|
-import androidx.compose.ui.unit.dp
|
|
|
import androidx.compose.ui.util.fastMap
|
|
|
import androidx.core.content.ContextCompat
|
|
|
import cafe.adriel.voyager.navigator.LocalNavigator
|
|
@@ -54,8 +39,6 @@ import tachiyomi.domain.library.service.LibraryPreferences.Companion.MANGA_HAS_U
|
|
|
import tachiyomi.domain.library.service.LibraryPreferences.Companion.MANGA_NON_COMPLETED
|
|
|
import tachiyomi.domain.library.service.LibraryPreferences.Companion.MANGA_NON_READ
|
|
|
import tachiyomi.domain.library.service.LibraryPreferences.Companion.MANGA_OUTSIDE_RELEASE_PERIOD
|
|
|
-import tachiyomi.domain.manga.interactor.MAX_GRACE_PERIOD
|
|
|
-import tachiyomi.presentation.core.components.WheelTextPicker
|
|
|
import tachiyomi.presentation.core.util.collectAsState
|
|
|
import uy.kohesive.injekt.Injekt
|
|
|
import uy.kohesive.injekt.api.get
|
|
@@ -141,13 +124,10 @@ object SettingsLibraryScreen : SearchableSettings {
|
|
|
val context = LocalContext.current
|
|
|
|
|
|
val libraryUpdateIntervalPref = libraryPreferences.libraryUpdateInterval()
|
|
|
- val libraryUpdateDeviceRestrictionPref = libraryPreferences.libraryUpdateDeviceRestriction()
|
|
|
- val libraryUpdateMangaRestrictionPref = libraryPreferences.libraryUpdateMangaRestriction()
|
|
|
val libraryUpdateCategoriesPref = libraryPreferences.libraryUpdateCategories()
|
|
|
val libraryUpdateCategoriesExcludePref = libraryPreferences.libraryUpdateCategoriesExclude()
|
|
|
|
|
|
val libraryUpdateInterval by libraryUpdateIntervalPref.collectAsState()
|
|
|
- val libraryUpdateMangaRestriction by libraryUpdateMangaRestrictionPref.collectAsState()
|
|
|
|
|
|
val included by libraryUpdateCategoriesPref.collectAsState()
|
|
|
val excluded by libraryUpdateCategoriesExcludePref.collectAsState()
|
|
@@ -168,25 +148,10 @@ object SettingsLibraryScreen : SearchableSettings {
|
|
|
},
|
|
|
)
|
|
|
}
|
|
|
- val leadRange by libraryPreferences.leadingExpectedDays().collectAsState()
|
|
|
- val followRange by libraryPreferences.followingExpectedDays().collectAsState()
|
|
|
|
|
|
- var showFetchRangesDialog by rememberSaveable { mutableStateOf(false) }
|
|
|
- if (showFetchRangesDialog) {
|
|
|
- LibraryExpectedRangeDialog(
|
|
|
- initialLead = leadRange,
|
|
|
- initialFollow = followRange,
|
|
|
- onDismissRequest = { showFetchRangesDialog = false },
|
|
|
- onValueChanged = { leadValue, followValue ->
|
|
|
- libraryPreferences.leadingExpectedDays().set(leadValue)
|
|
|
- libraryPreferences.followingExpectedDays().set(followValue)
|
|
|
- showFetchRangesDialog = false
|
|
|
- },
|
|
|
- )
|
|
|
- }
|
|
|
return Preference.PreferenceGroup(
|
|
|
title = stringResource(R.string.pref_category_library_update),
|
|
|
- preferenceItems = listOfNotNull(
|
|
|
+ preferenceItems = listOf(
|
|
|
Preference.PreferenceItem.ListPreference(
|
|
|
pref = libraryUpdateIntervalPref,
|
|
|
title = stringResource(R.string.pref_library_update_interval),
|
|
@@ -204,7 +169,7 @@ object SettingsLibraryScreen : SearchableSettings {
|
|
|
},
|
|
|
),
|
|
|
Preference.PreferenceItem.MultiSelectListPreference(
|
|
|
- pref = libraryUpdateDeviceRestrictionPref,
|
|
|
+ pref = libraryPreferences.libraryUpdateDeviceRestriction(),
|
|
|
enabled = libraryUpdateInterval > 0,
|
|
|
title = stringResource(R.string.pref_library_update_restriction),
|
|
|
subtitle = stringResource(R.string.restrictions),
|
|
@@ -241,7 +206,7 @@ object SettingsLibraryScreen : SearchableSettings {
|
|
|
subtitle = stringResource(R.string.pref_library_update_refresh_trackers_summary),
|
|
|
),
|
|
|
Preference.PreferenceItem.MultiSelectListPreference(
|
|
|
- pref = libraryUpdateMangaRestrictionPref,
|
|
|
+ pref = libraryPreferences.libraryUpdateMangaRestriction(),
|
|
|
title = stringResource(R.string.pref_library_update_manga_restriction),
|
|
|
entries = mapOf(
|
|
|
MANGA_HAS_UNREAD to stringResource(R.string.pref_update_only_completely_read),
|
|
@@ -250,17 +215,6 @@ object SettingsLibraryScreen : SearchableSettings {
|
|
|
MANGA_OUTSIDE_RELEASE_PERIOD to stringResource(R.string.pref_update_only_in_release_period),
|
|
|
),
|
|
|
),
|
|
|
- Preference.PreferenceItem.TextPreference(
|
|
|
- title = stringResource(R.string.pref_update_release_grace_period),
|
|
|
- subtitle = listOf(
|
|
|
- pluralStringResource(R.plurals.pref_update_release_leading_days, leadRange, leadRange),
|
|
|
- pluralStringResource(R.plurals.pref_update_release_following_days, followRange, followRange),
|
|
|
- ).joinToString(),
|
|
|
- onClick = { showFetchRangesDialog = true },
|
|
|
- ).takeIf { MANGA_OUTSIDE_RELEASE_PERIOD in libraryUpdateMangaRestriction },
|
|
|
- Preference.PreferenceItem.InfoPreference(
|
|
|
- title = stringResource(R.string.pref_update_release_grace_period_info),
|
|
|
- ).takeIf { MANGA_OUTSIDE_RELEASE_PERIOD in libraryUpdateMangaRestriction },
|
|
|
Preference.PreferenceItem.SwitchPreference(
|
|
|
pref = libraryPreferences.newShowUpdatesCount(),
|
|
|
title = stringResource(R.string.pref_library_update_show_tab_badge),
|
|
@@ -299,79 +253,4 @@ object SettingsLibraryScreen : SearchableSettings {
|
|
|
),
|
|
|
)
|
|
|
}
|
|
|
-
|
|
|
- @Composable
|
|
|
- private fun LibraryExpectedRangeDialog(
|
|
|
- initialLead: Int,
|
|
|
- initialFollow: Int,
|
|
|
- onDismissRequest: () -> Unit,
|
|
|
- onValueChanged: (portrait: Int, landscape: Int) -> Unit,
|
|
|
- ) {
|
|
|
- var leadValue by rememberSaveable { mutableIntStateOf(initialLead) }
|
|
|
- var followValue by rememberSaveable { mutableIntStateOf(initialFollow) }
|
|
|
-
|
|
|
- AlertDialog(
|
|
|
- onDismissRequest = onDismissRequest,
|
|
|
- title = { Text(text = stringResource(R.string.pref_update_release_grace_period)) },
|
|
|
- text = {
|
|
|
- Column {
|
|
|
- Row(
|
|
|
- horizontalArrangement = Arrangement.spacedBy(8.dp),
|
|
|
- ) {
|
|
|
- Text(
|
|
|
- modifier = Modifier.weight(1f),
|
|
|
- text = pluralStringResource(R.plurals.pref_update_release_leading_days, leadValue, leadValue),
|
|
|
- textAlign = TextAlign.Center,
|
|
|
- maxLines = 1,
|
|
|
- style = MaterialTheme.typography.labelMedium,
|
|
|
- )
|
|
|
- Text(
|
|
|
- modifier = Modifier.weight(1f),
|
|
|
- text = pluralStringResource(R.plurals.pref_update_release_following_days, followValue, followValue),
|
|
|
- textAlign = TextAlign.Center,
|
|
|
- maxLines = 1,
|
|
|
- style = MaterialTheme.typography.labelMedium,
|
|
|
- )
|
|
|
- }
|
|
|
- }
|
|
|
- BoxWithConstraints(
|
|
|
- modifier = Modifier.fillMaxWidth(),
|
|
|
- contentAlignment = Alignment.Center,
|
|
|
- ) {
|
|
|
- val size = DpSize(width = maxWidth / 2, height = 128.dp)
|
|
|
- val items = (0..MAX_GRACE_PERIOD).map(Int::toString)
|
|
|
- Row(
|
|
|
- horizontalArrangement = Arrangement.spacedBy(8.dp),
|
|
|
- ) {
|
|
|
- WheelTextPicker(
|
|
|
- size = size,
|
|
|
- items = items,
|
|
|
- startIndex = leadValue,
|
|
|
- onSelectionChanged = {
|
|
|
- leadValue = it
|
|
|
- },
|
|
|
- )
|
|
|
- WheelTextPicker(
|
|
|
- size = size,
|
|
|
- items = items,
|
|
|
- startIndex = followValue,
|
|
|
- onSelectionChanged = {
|
|
|
- followValue = it
|
|
|
- },
|
|
|
- )
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
- dismissButton = {
|
|
|
- TextButton(onClick = onDismissRequest) {
|
|
|
- Text(text = stringResource(android.R.string.cancel))
|
|
|
- }
|
|
|
- },
|
|
|
- confirmButton = {
|
|
|
- TextButton(onClick = { onValueChanged(leadValue, followValue) }) {
|
|
|
- Text(text = stringResource(R.string.action_ok))
|
|
|
- }
|
|
|
- },
|
|
|
- )
|
|
|
- }
|
|
|
}
|