mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-10 05:57:48 +01:00
Clean up preference extensions/items a bit
This commit is contained in:
parent
7a4680603d
commit
cf14831fbe
24 changed files with 101 additions and 219 deletions
|
@ -31,7 +31,7 @@ class PreferenceMutableState<T>(
|
|||
}
|
||||
|
||||
override fun component2(): (T) -> Unit {
|
||||
return { preference.set(it) }
|
||||
return preference::set
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@ import androidx.compose.ui.platform.LocalConfiguration
|
|||
import androidx.compose.ui.res.stringResource
|
||||
import eu.kanade.presentation.components.TabbedDialog
|
||||
import eu.kanade.presentation.components.TabbedDialogPaddings
|
||||
import eu.kanade.presentation.util.collectAsState
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.ui.library.LibrarySettingsScreenModel
|
||||
import tachiyomi.core.preference.TriState
|
||||
|
@ -31,6 +30,7 @@ import tachiyomi.presentation.core.components.SettingsChipRow
|
|||
import tachiyomi.presentation.core.components.SliderItem
|
||||
import tachiyomi.presentation.core.components.SortItem
|
||||
import tachiyomi.presentation.core.components.TriStateItem
|
||||
import tachiyomi.presentation.core.util.collectAsState
|
||||
|
||||
@Composable
|
||||
fun LibrarySettingsDialog(
|
||||
|
@ -211,59 +211,35 @@ private fun ColumnScope.DisplayPage(
|
|||
} else {
|
||||
stringResource(R.string.label_default)
|
||||
},
|
||||
onChange = { columnPreference.set(it) },
|
||||
onChange = columnPreference::set,
|
||||
)
|
||||
}
|
||||
|
||||
HeadingItem(R.string.overlay_header)
|
||||
val downloadBadge by screenModel.libraryPreferences.downloadBadge().collectAsState()
|
||||
CheckboxItem(
|
||||
label = stringResource(R.string.action_display_download_badge),
|
||||
checked = downloadBadge,
|
||||
onClick = {
|
||||
screenModel.togglePreference(LibraryPreferences::downloadBadge)
|
||||
},
|
||||
pref = screenModel.libraryPreferences.downloadBadge(),
|
||||
)
|
||||
val localBadge by screenModel.libraryPreferences.localBadge().collectAsState()
|
||||
CheckboxItem(
|
||||
label = stringResource(R.string.action_display_local_badge),
|
||||
checked = localBadge,
|
||||
onClick = {
|
||||
screenModel.togglePreference(LibraryPreferences::localBadge)
|
||||
},
|
||||
pref = screenModel.libraryPreferences.localBadge(),
|
||||
)
|
||||
val languageBadge by screenModel.libraryPreferences.languageBadge().collectAsState()
|
||||
CheckboxItem(
|
||||
label = stringResource(R.string.action_display_language_badge),
|
||||
checked = languageBadge,
|
||||
onClick = {
|
||||
screenModel.togglePreference(LibraryPreferences::languageBadge)
|
||||
},
|
||||
pref = screenModel.libraryPreferences.languageBadge(),
|
||||
)
|
||||
val showContinueReadingButton by screenModel.libraryPreferences.showContinueReadingButton().collectAsState()
|
||||
CheckboxItem(
|
||||
label = stringResource(R.string.action_display_show_continue_reading_button),
|
||||
checked = showContinueReadingButton,
|
||||
onClick = {
|
||||
screenModel.togglePreference(LibraryPreferences::showContinueReadingButton)
|
||||
},
|
||||
pref = screenModel.libraryPreferences.showContinueReadingButton(),
|
||||
)
|
||||
|
||||
HeadingItem(R.string.tabs_header)
|
||||
val categoryTabs by screenModel.libraryPreferences.categoryTabs().collectAsState()
|
||||
CheckboxItem(
|
||||
label = stringResource(R.string.action_display_show_tabs),
|
||||
checked = categoryTabs,
|
||||
onClick = {
|
||||
screenModel.togglePreference(LibraryPreferences::categoryTabs)
|
||||
},
|
||||
pref = screenModel.libraryPreferences.categoryTabs(),
|
||||
)
|
||||
val categoryNumberOfItems by screenModel.libraryPreferences.categoryNumberOfItems().collectAsState()
|
||||
CheckboxItem(
|
||||
label = stringResource(R.string.action_display_show_number_of_items),
|
||||
checked = categoryNumberOfItems,
|
||||
onClick = {
|
||||
screenModel.togglePreference(LibraryPreferences::categoryNumberOfItems)
|
||||
},
|
||||
pref = screenModel.libraryPreferences.categoryNumberOfItems(),
|
||||
)
|
||||
}
|
||||
|
|
|
@ -22,10 +22,10 @@ import eu.kanade.presentation.more.settings.widget.MultiSelectListPreferenceWidg
|
|||
import eu.kanade.presentation.more.settings.widget.SwitchPreferenceWidget
|
||||
import eu.kanade.presentation.more.settings.widget.TextPreferenceWidget
|
||||
import eu.kanade.presentation.more.settings.widget.TrackingPreferenceWidget
|
||||
import eu.kanade.presentation.util.collectAsState
|
||||
import kotlinx.coroutines.launch
|
||||
import tachiyomi.core.preference.PreferenceStore
|
||||
import tachiyomi.presentation.core.components.SliderItem
|
||||
import tachiyomi.presentation.core.util.collectAsState
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
||||
|
|
|
@ -30,7 +30,6 @@ import eu.kanade.domain.base.BasePreferences
|
|||
import eu.kanade.presentation.more.settings.Preference
|
||||
import eu.kanade.presentation.more.settings.screen.advanced.ClearDatabaseScreen
|
||||
import eu.kanade.presentation.more.settings.screen.debug.DebugInfoScreen
|
||||
import eu.kanade.presentation.util.collectAsState
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.cache.ChapterCache
|
||||
import eu.kanade.tachiyomi.data.download.DownloadCache
|
||||
|
@ -65,6 +64,7 @@ import tachiyomi.core.util.lang.withUIContext
|
|||
import tachiyomi.core.util.system.logcat
|
||||
import tachiyomi.domain.library.service.LibraryPreferences
|
||||
import tachiyomi.domain.manga.repository.MangaRepository
|
||||
import tachiyomi.presentation.core.util.collectAsState
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import java.io.File
|
||||
|
|
|
@ -21,7 +21,6 @@ import eu.kanade.domain.ui.model.TabletUiMode
|
|||
import eu.kanade.domain.ui.model.ThemeMode
|
||||
import eu.kanade.domain.ui.model.setAppCompatDelegateThemeMode
|
||||
import eu.kanade.presentation.more.settings.Preference
|
||||
import eu.kanade.presentation.util.collectAsState
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.util.system.LocaleHelper
|
||||
import eu.kanade.tachiyomi.util.system.toast
|
||||
|
@ -29,6 +28,7 @@ import kotlinx.coroutines.flow.collectLatest
|
|||
import kotlinx.coroutines.flow.drop
|
||||
import kotlinx.coroutines.flow.merge
|
||||
import org.xmlpull.v1.XmlPullParser
|
||||
import tachiyomi.presentation.core.util.collectAsState
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import java.util.Date
|
||||
|
|
|
@ -42,7 +42,6 @@ import androidx.core.net.toUri
|
|||
import com.hippo.unifile.UniFile
|
||||
import eu.kanade.presentation.extensions.RequestStoragePermission
|
||||
import eu.kanade.presentation.more.settings.Preference
|
||||
import eu.kanade.presentation.util.collectAsState
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.backup.BackupConst
|
||||
import eu.kanade.tachiyomi.data.backup.BackupCreateJob
|
||||
|
@ -57,6 +56,7 @@ import kotlinx.coroutines.launch
|
|||
import tachiyomi.domain.backup.service.BackupPreferences
|
||||
import tachiyomi.presentation.core.components.ScrollbarLazyColumn
|
||||
import tachiyomi.presentation.core.components.material.Divider
|
||||
import tachiyomi.presentation.core.util.collectAsState
|
||||
import tachiyomi.presentation.core.util.isScrolledToEnd
|
||||
import tachiyomi.presentation.core.util.isScrolledToStart
|
||||
import uy.kohesive.injekt.Injekt
|
||||
|
|
|
@ -22,12 +22,12 @@ import com.hippo.unifile.UniFile
|
|||
import eu.kanade.presentation.category.visualName
|
||||
import eu.kanade.presentation.more.settings.Preference
|
||||
import eu.kanade.presentation.more.settings.widget.TriStateListDialog
|
||||
import eu.kanade.presentation.util.collectAsState
|
||||
import eu.kanade.tachiyomi.R
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import tachiyomi.domain.category.interactor.GetCategories
|
||||
import tachiyomi.domain.category.model.Category
|
||||
import tachiyomi.domain.download.service.DownloadPreferences
|
||||
import tachiyomi.presentation.core.util.collectAsState
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import java.io.File
|
||||
|
|
|
@ -36,7 +36,6 @@ import cafe.adriel.voyager.navigator.currentOrThrow
|
|||
import eu.kanade.presentation.category.visualName
|
||||
import eu.kanade.presentation.more.settings.Preference
|
||||
import eu.kanade.presentation.more.settings.widget.TriStateListDialog
|
||||
import eu.kanade.presentation.util.collectAsState
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.library.LibraryUpdateJob
|
||||
import eu.kanade.tachiyomi.data.track.TrackManager
|
||||
|
@ -58,6 +57,7 @@ import tachiyomi.domain.library.service.LibraryPreferences.Companion.MANGA_NON_R
|
|||
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
|
||||
|
||||
|
|
|
@ -9,12 +9,12 @@ import androidx.compose.runtime.remember
|
|||
import androidx.compose.ui.platform.LocalView
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import eu.kanade.presentation.more.settings.Preference
|
||||
import eu.kanade.presentation.util.collectAsState
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.ui.reader.setting.OrientationType
|
||||
import eu.kanade.tachiyomi.ui.reader.setting.ReaderPreferences
|
||||
import eu.kanade.tachiyomi.ui.reader.setting.ReadingModeType
|
||||
import eu.kanade.tachiyomi.util.system.isReleaseBuildType
|
||||
import tachiyomi.presentation.core.util.collectAsState
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import java.text.NumberFormat
|
||||
|
|
|
@ -10,11 +10,11 @@ import androidx.compose.ui.res.pluralStringResource
|
|||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import eu.kanade.presentation.more.settings.Preference
|
||||
import eu.kanade.presentation.util.collectAsState
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.core.security.SecurityPreferences
|
||||
import eu.kanade.tachiyomi.util.system.AuthenticatorUtil.authenticate
|
||||
import eu.kanade.tachiyomi.util.system.AuthenticatorUtil.isAuthenticationSupported
|
||||
import tachiyomi.presentation.core.util.collectAsState
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
||||
|
|
|
@ -11,14 +11,13 @@ import androidx.core.graphics.alpha
|
|||
import androidx.core.graphics.blue
|
||||
import androidx.core.graphics.green
|
||||
import androidx.core.graphics.red
|
||||
import eu.kanade.presentation.util.collectAsState
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.ui.reader.setting.ReaderPreferences
|
||||
import eu.kanade.tachiyomi.ui.reader.setting.ReaderSettingsScreenModel
|
||||
import tachiyomi.core.preference.getAndSet
|
||||
import tachiyomi.presentation.core.components.CheckboxItem
|
||||
import tachiyomi.presentation.core.components.SettingsChipRow
|
||||
import tachiyomi.presentation.core.components.SliderItem
|
||||
import tachiyomi.presentation.core.util.collectAsState
|
||||
|
||||
@Composable
|
||||
internal fun ColumnScope.ColorFilterPage(screenModel: ReaderSettingsScreenModel) {
|
||||
|
@ -44,10 +43,7 @@ internal fun ColumnScope.ColorFilterPage(screenModel: ReaderSettingsScreenModel)
|
|||
val customBrightness by screenModel.preferences.customBrightness().collectAsState()
|
||||
CheckboxItem(
|
||||
label = stringResource(R.string.pref_custom_brightness),
|
||||
checked = customBrightness,
|
||||
onClick = {
|
||||
screenModel.togglePreference(ReaderPreferences::customBrightness)
|
||||
},
|
||||
pref = screenModel.preferences.customBrightness(),
|
||||
)
|
||||
|
||||
/**
|
||||
|
@ -71,10 +67,7 @@ internal fun ColumnScope.ColorFilterPage(screenModel: ReaderSettingsScreenModel)
|
|||
val colorFilter by screenModel.preferences.colorFilter().collectAsState()
|
||||
CheckboxItem(
|
||||
label = stringResource(R.string.pref_custom_color_filter),
|
||||
checked = colorFilter,
|
||||
onClick = {
|
||||
screenModel.togglePreference(ReaderPreferences::colorFilter)
|
||||
},
|
||||
pref = screenModel.preferences.colorFilter(),
|
||||
)
|
||||
if (colorFilter) {
|
||||
val colorFilterValue by screenModel.preferences.colorFilterValue().collectAsState()
|
||||
|
@ -135,21 +128,13 @@ internal fun ColumnScope.ColorFilterPage(screenModel: ReaderSettingsScreenModel)
|
|||
}
|
||||
}
|
||||
|
||||
val grayscale by screenModel.preferences.grayscale().collectAsState()
|
||||
CheckboxItem(
|
||||
label = stringResource(R.string.pref_grayscale),
|
||||
checked = grayscale,
|
||||
onClick = {
|
||||
screenModel.togglePreference(ReaderPreferences::grayscale)
|
||||
},
|
||||
pref = screenModel.preferences.grayscale(),
|
||||
)
|
||||
val invertedColors by screenModel.preferences.invertedColors().collectAsState()
|
||||
CheckboxItem(
|
||||
label = stringResource(R.string.pref_inverted_colors),
|
||||
checked = invertedColors,
|
||||
onClick = {
|
||||
screenModel.togglePreference(ReaderPreferences::invertedColors)
|
||||
},
|
||||
pref = screenModel.preferences.invertedColors(),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -6,12 +6,11 @@ import androidx.compose.material3.Text
|
|||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import eu.kanade.presentation.util.collectAsState
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.ui.reader.setting.ReaderPreferences
|
||||
import eu.kanade.tachiyomi.ui.reader.setting.ReaderSettingsScreenModel
|
||||
import tachiyomi.presentation.core.components.CheckboxItem
|
||||
import tachiyomi.presentation.core.components.SettingsChipRow
|
||||
import tachiyomi.presentation.core.util.collectAsState
|
||||
|
||||
private val themes = listOf(
|
||||
R.string.black_background to 1,
|
||||
|
@ -33,67 +32,39 @@ internal fun ColumnScope.GeneralPage(screenModel: ReaderSettingsScreenModel) {
|
|||
}
|
||||
}
|
||||
|
||||
val showPageNumber by screenModel.preferences.showPageNumber().collectAsState()
|
||||
CheckboxItem(
|
||||
label = stringResource(R.string.pref_show_page_number),
|
||||
checked = showPageNumber,
|
||||
onClick = {
|
||||
screenModel.togglePreference(ReaderPreferences::showPageNumber)
|
||||
},
|
||||
pref = screenModel.preferences.showPageNumber(),
|
||||
)
|
||||
|
||||
val fullscreen by screenModel.preferences.fullscreen().collectAsState()
|
||||
CheckboxItem(
|
||||
label = stringResource(R.string.pref_fullscreen),
|
||||
checked = fullscreen,
|
||||
onClick = {
|
||||
screenModel.togglePreference(ReaderPreferences::fullscreen)
|
||||
},
|
||||
pref = screenModel.preferences.fullscreen(),
|
||||
)
|
||||
|
||||
// TODO: hide if there's no cutout
|
||||
val cutoutShort by screenModel.preferences.cutoutShort().collectAsState()
|
||||
CheckboxItem(
|
||||
label = stringResource(R.string.pref_cutout_short),
|
||||
checked = cutoutShort,
|
||||
onClick = {
|
||||
screenModel.togglePreference(ReaderPreferences::cutoutShort)
|
||||
},
|
||||
pref = screenModel.preferences.cutoutShort(),
|
||||
)
|
||||
|
||||
val keepScreenOn by screenModel.preferences.keepScreenOn().collectAsState()
|
||||
CheckboxItem(
|
||||
label = stringResource(R.string.pref_keep_screen_on),
|
||||
checked = keepScreenOn,
|
||||
onClick = {
|
||||
screenModel.togglePreference(ReaderPreferences::keepScreenOn)
|
||||
},
|
||||
pref = screenModel.preferences.keepScreenOn(),
|
||||
)
|
||||
|
||||
val readWithLongTap by screenModel.preferences.readWithLongTap().collectAsState()
|
||||
CheckboxItem(
|
||||
label = stringResource(R.string.pref_read_with_long_tap),
|
||||
checked = readWithLongTap,
|
||||
onClick = {
|
||||
screenModel.togglePreference(ReaderPreferences::readWithLongTap)
|
||||
},
|
||||
pref = screenModel.preferences.readWithLongTap(),
|
||||
)
|
||||
|
||||
val alwaysShowChapterTransition by screenModel.preferences.alwaysShowChapterTransition().collectAsState()
|
||||
CheckboxItem(
|
||||
label = stringResource(R.string.pref_always_show_chapter_transition),
|
||||
checked = alwaysShowChapterTransition,
|
||||
onClick = {
|
||||
screenModel.togglePreference(ReaderPreferences::alwaysShowChapterTransition)
|
||||
},
|
||||
pref = screenModel.preferences.alwaysShowChapterTransition(),
|
||||
)
|
||||
|
||||
val pageTransitions by screenModel.preferences.pageTransitions().collectAsState()
|
||||
CheckboxItem(
|
||||
label = stringResource(R.string.pref_page_transitions),
|
||||
checked = pageTransitions,
|
||||
onClick = {
|
||||
screenModel.togglePreference(ReaderPreferences::pageTransitions)
|
||||
},
|
||||
pref = screenModel.preferences.pageTransitions(),
|
||||
)
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@ import androidx.compose.runtime.remember
|
|||
import androidx.compose.ui.res.stringResource
|
||||
import eu.kanade.domain.manga.model.orientationType
|
||||
import eu.kanade.domain.manga.model.readingModeType
|
||||
import eu.kanade.presentation.util.collectAsState
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.ui.reader.setting.OrientationType
|
||||
import eu.kanade.tachiyomi.ui.reader.setting.ReaderPreferences
|
||||
|
@ -22,6 +21,7 @@ import tachiyomi.presentation.core.components.CheckboxItem
|
|||
import tachiyomi.presentation.core.components.HeadingItem
|
||||
import tachiyomi.presentation.core.components.SettingsChipRow
|
||||
import tachiyomi.presentation.core.components.SliderItem
|
||||
import tachiyomi.presentation.core.util.collectAsState
|
||||
import java.text.NumberFormat
|
||||
|
||||
private val readingModeOptions = ReadingModeType.entries.map { it.stringRes to it }
|
||||
|
@ -98,70 +98,44 @@ private fun ColumnScope.PagerViewerSettings(screenModel: ReaderSettingsScreenMod
|
|||
}
|
||||
}
|
||||
|
||||
val cropBorders by screenModel.preferences.cropBorders().collectAsState()
|
||||
CheckboxItem(
|
||||
label = stringResource(R.string.pref_crop_borders),
|
||||
checked = cropBorders,
|
||||
onClick = {
|
||||
screenModel.togglePreference(ReaderPreferences::cropBorders)
|
||||
},
|
||||
pref = screenModel.preferences.cropBorders(),
|
||||
)
|
||||
|
||||
val landscapeZoom by screenModel.preferences.landscapeZoom().collectAsState()
|
||||
CheckboxItem(
|
||||
label = stringResource(R.string.pref_landscape_zoom),
|
||||
checked = landscapeZoom,
|
||||
onClick = {
|
||||
screenModel.togglePreference(ReaderPreferences::landscapeZoom)
|
||||
},
|
||||
pref = screenModel.preferences.landscapeZoom(),
|
||||
)
|
||||
|
||||
val navigateToPan by screenModel.preferences.navigateToPan().collectAsState()
|
||||
CheckboxItem(
|
||||
label = stringResource(R.string.pref_navigate_pan),
|
||||
checked = navigateToPan,
|
||||
onClick = {
|
||||
screenModel.togglePreference(ReaderPreferences::navigateToPan)
|
||||
},
|
||||
pref = screenModel.preferences.navigateToPan(),
|
||||
)
|
||||
|
||||
val dualPageSplitPaged by screenModel.preferences.dualPageSplitPaged().collectAsState()
|
||||
CheckboxItem(
|
||||
label = stringResource(R.string.pref_dual_page_split),
|
||||
checked = dualPageSplitPaged,
|
||||
onClick = {
|
||||
screenModel.togglePreference(ReaderPreferences::dualPageSplitPaged)
|
||||
},
|
||||
pref = screenModel.preferences.dualPageSplitPaged(),
|
||||
)
|
||||
|
||||
if (dualPageSplitPaged) {
|
||||
val dualPageInvertPaged by screenModel.preferences.dualPageInvertPaged().collectAsState()
|
||||
CheckboxItem(
|
||||
label = stringResource(R.string.pref_dual_page_invert),
|
||||
checked = dualPageInvertPaged,
|
||||
onClick = {
|
||||
screenModel.togglePreference(ReaderPreferences::dualPageInvertPaged)
|
||||
},
|
||||
pref = screenModel.preferences.dualPageInvertPaged(),
|
||||
)
|
||||
}
|
||||
|
||||
val dualPageRotateToFit by screenModel.preferences.dualPageRotateToFit().collectAsState()
|
||||
CheckboxItem(
|
||||
label = stringResource(R.string.pref_page_rotate),
|
||||
checked = dualPageRotateToFit,
|
||||
onClick = {
|
||||
screenModel.togglePreference(ReaderPreferences::dualPageRotateToFit)
|
||||
},
|
||||
pref = screenModel.preferences.dualPageRotateToFit(),
|
||||
)
|
||||
|
||||
if (dualPageRotateToFit) {
|
||||
val dualPageRotateToFitInvert by screenModel.preferences.dualPageRotateToFitInvert().collectAsState()
|
||||
CheckboxItem(
|
||||
label = stringResource(R.string.pref_page_rotate_invert),
|
||||
checked = dualPageRotateToFitInvert,
|
||||
onClick = {
|
||||
screenModel.togglePreference(ReaderPreferences::dualPageRotateToFitInvert)
|
||||
},
|
||||
pref = screenModel.preferences.dualPageRotateToFitInvert(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -193,55 +167,34 @@ private fun ColumnScope.WebtoonViewerSettings(screenModel: ReaderSettingsScreenM
|
|||
},
|
||||
)
|
||||
|
||||
val cropBordersWebtoon by screenModel.preferences.cropBordersWebtoon().collectAsState()
|
||||
CheckboxItem(
|
||||
label = stringResource(R.string.pref_crop_borders),
|
||||
checked = cropBordersWebtoon,
|
||||
onClick = {
|
||||
screenModel.togglePreference(ReaderPreferences::cropBordersWebtoon)
|
||||
},
|
||||
pref = screenModel.preferences.cropBordersWebtoon(),
|
||||
)
|
||||
|
||||
val dualPageSplitWebtoon by screenModel.preferences.dualPageSplitWebtoon().collectAsState()
|
||||
CheckboxItem(
|
||||
label = stringResource(R.string.pref_dual_page_split),
|
||||
checked = dualPageSplitWebtoon,
|
||||
onClick = {
|
||||
screenModel.togglePreference(ReaderPreferences::dualPageSplitWebtoon)
|
||||
},
|
||||
pref = screenModel.preferences.dualPageSplitWebtoon(),
|
||||
)
|
||||
|
||||
if (dualPageSplitWebtoon) {
|
||||
val dualPageInvertWebtoon by screenModel.preferences.dualPageInvertWebtoon()
|
||||
.collectAsState()
|
||||
CheckboxItem(
|
||||
label = stringResource(R.string.pref_dual_page_invert),
|
||||
checked = dualPageInvertWebtoon,
|
||||
onClick = {
|
||||
screenModel.togglePreference(ReaderPreferences::dualPageInvertWebtoon)
|
||||
},
|
||||
pref = screenModel.preferences.dualPageInvertWebtoon(),
|
||||
)
|
||||
}
|
||||
|
||||
if (!isReleaseBuildType) {
|
||||
val longStripSplitWebtoon by screenModel.preferences.longStripSplitWebtoon()
|
||||
.collectAsState()
|
||||
CheckboxItem(
|
||||
label = stringResource(R.string.pref_long_strip_split),
|
||||
checked = longStripSplitWebtoon,
|
||||
onClick = {
|
||||
screenModel.togglePreference(ReaderPreferences::longStripSplitWebtoon)
|
||||
},
|
||||
pref = screenModel.preferences.longStripSplitWebtoon(),
|
||||
)
|
||||
}
|
||||
|
||||
val webtoonDoubleTapZoomEnabled by screenModel.preferences.webtoonDoubleTapZoomEnabled().collectAsState()
|
||||
CheckboxItem(
|
||||
label = stringResource(R.string.pref_double_tap_zoom),
|
||||
checked = webtoonDoubleTapZoomEnabled,
|
||||
onClick = {
|
||||
screenModel.togglePreference(ReaderPreferences::webtoonDoubleTapZoomEnabled)
|
||||
},
|
||||
pref = screenModel.preferences.webtoonDoubleTapZoomEnabled(),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -14,8 +14,6 @@ import eu.kanade.tachiyomi.network.NetworkPreferences
|
|||
import eu.kanade.tachiyomi.network.PREF_DOH_CLOUDFLARE
|
||||
import eu.kanade.tachiyomi.ui.reader.setting.OrientationType
|
||||
import eu.kanade.tachiyomi.ui.reader.setting.ReaderPreferences
|
||||
import eu.kanade.tachiyomi.util.preference.minusAssign
|
||||
import eu.kanade.tachiyomi.util.preference.plusAssign
|
||||
import eu.kanade.tachiyomi.util.system.DeviceUtil
|
||||
import eu.kanade.tachiyomi.util.system.isReleaseBuildType
|
||||
import eu.kanade.tachiyomi.util.system.toast
|
||||
|
@ -23,6 +21,8 @@ import eu.kanade.tachiyomi.util.system.workManager
|
|||
import tachiyomi.core.preference.PreferenceStore
|
||||
import tachiyomi.core.preference.TriState
|
||||
import tachiyomi.core.preference.getEnum
|
||||
import tachiyomi.core.preference.minusAssign
|
||||
import tachiyomi.core.preference.plusAssign
|
||||
import tachiyomi.domain.backup.service.BackupPreferences
|
||||
import tachiyomi.domain.library.service.LibraryPreferences
|
||||
import tachiyomi.domain.library.service.LibraryPreferences.Companion.MANGA_NON_COMPLETED
|
||||
|
|
|
@ -11,7 +11,6 @@ import eu.kanade.tachiyomi.extension.model.LoadResult
|
|||
import eu.kanade.tachiyomi.extension.util.ExtensionInstallReceiver
|
||||
import eu.kanade.tachiyomi.extension.util.ExtensionInstaller
|
||||
import eu.kanade.tachiyomi.extension.util.ExtensionLoader
|
||||
import eu.kanade.tachiyomi.util.preference.plusAssign
|
||||
import eu.kanade.tachiyomi.util.system.toast
|
||||
import kotlinx.coroutines.async
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
@ -19,6 +18,7 @@ import kotlinx.coroutines.flow.MutableStateFlow
|
|||
import kotlinx.coroutines.flow.asStateFlow
|
||||
import kotlinx.coroutines.flow.emptyFlow
|
||||
import logcat.LogPriority
|
||||
import tachiyomi.core.preference.plusAssign
|
||||
import tachiyomi.core.util.lang.launchNow
|
||||
import tachiyomi.core.util.lang.withUIContext
|
||||
import tachiyomi.core.util.system.logcat
|
||||
|
|
|
@ -4,7 +4,6 @@ import cafe.adriel.voyager.core.model.ScreenModel
|
|||
import cafe.adriel.voyager.core.model.coroutineScope
|
||||
import eu.kanade.domain.base.BasePreferences
|
||||
import eu.kanade.tachiyomi.data.track.TrackManager
|
||||
import eu.kanade.tachiyomi.util.preference.toggle
|
||||
import tachiyomi.core.preference.Preference
|
||||
import tachiyomi.core.preference.TriState
|
||||
import tachiyomi.core.preference.getAndSet
|
||||
|
@ -29,10 +28,6 @@ class LibrarySettingsScreenModel(
|
|||
val trackServices
|
||||
get() = trackManager.services.filter { it.isLogged }
|
||||
|
||||
fun togglePreference(preference: (LibraryPreferences) -> Preference<Boolean>) {
|
||||
preference(libraryPreferences).toggle()
|
||||
}
|
||||
|
||||
fun toggleFilter(preference: (LibraryPreferences) -> Preference<TriState>) {
|
||||
preference(libraryPreferences).getAndSet {
|
||||
it.next()
|
||||
|
|
|
@ -59,7 +59,6 @@ import eu.kanade.presentation.components.IncognitoModeBannerBackgroundColor
|
|||
import eu.kanade.presentation.components.IndexingBannerBackgroundColor
|
||||
import eu.kanade.presentation.util.AssistContentScreen
|
||||
import eu.kanade.presentation.util.DefaultNavigatorScreenTransition
|
||||
import eu.kanade.presentation.util.collectAsState
|
||||
import eu.kanade.tachiyomi.BuildConfig
|
||||
import eu.kanade.tachiyomi.Migrations
|
||||
import eu.kanade.tachiyomi.R
|
||||
|
@ -93,6 +92,7 @@ import tachiyomi.core.util.system.logcat
|
|||
import tachiyomi.domain.library.service.LibraryPreferences
|
||||
import tachiyomi.domain.release.interactor.GetApplicationRelease
|
||||
import tachiyomi.presentation.core.components.material.Scaffold
|
||||
import tachiyomi.presentation.core.util.collectAsState
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
|
|
@ -73,7 +73,6 @@ import eu.kanade.tachiyomi.ui.reader.setting.ReadingModeType
|
|||
import eu.kanade.tachiyomi.ui.reader.viewer.ReaderProgressIndicator
|
||||
import eu.kanade.tachiyomi.ui.reader.viewer.pager.R2LPagerViewer
|
||||
import eu.kanade.tachiyomi.ui.webview.WebViewActivity
|
||||
import eu.kanade.tachiyomi.util.preference.toggle
|
||||
import eu.kanade.tachiyomi.util.system.applySystemAnimatorScale
|
||||
import eu.kanade.tachiyomi.util.system.hasDisplayCutout
|
||||
import eu.kanade.tachiyomi.util.system.isNightMode
|
||||
|
@ -95,6 +94,7 @@ import kotlinx.coroutines.flow.sample
|
|||
import kotlinx.coroutines.launch
|
||||
import logcat.LogPriority
|
||||
import tachiyomi.core.Constants
|
||||
import tachiyomi.core.preference.toggle
|
||||
import tachiyomi.core.util.lang.launchIO
|
||||
import tachiyomi.core.util.lang.launchNonCancellable
|
||||
import tachiyomi.core.util.lang.withUIContext
|
||||
|
|
|
@ -50,9 +50,7 @@ internal class HttpPageLoader(
|
|||
}
|
||||
}
|
||||
.filter { it.status == Page.State.QUEUE }
|
||||
.collect {
|
||||
_loadPage(it)
|
||||
}
|
||||
.collect(::internalLoadPage)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -80,32 +78,30 @@ internal class HttpPageLoader(
|
|||
/**
|
||||
* Loads a page through the queue. Handles re-enqueueing pages if they were evicted from the cache.
|
||||
*/
|
||||
override suspend fun loadPage(page: ReaderPage) {
|
||||
withIOContext {
|
||||
val imageUrl = page.imageUrl
|
||||
override suspend fun loadPage(page: ReaderPage) = withIOContext {
|
||||
val imageUrl = page.imageUrl
|
||||
|
||||
// Check if the image has been deleted
|
||||
if (page.status == Page.State.READY && imageUrl != null && !chapterCache.isImageInCache(imageUrl)) {
|
||||
page.status = Page.State.QUEUE
|
||||
}
|
||||
// Check if the image has been deleted
|
||||
if (page.status == Page.State.READY && imageUrl != null && !chapterCache.isImageInCache(imageUrl)) {
|
||||
page.status = Page.State.QUEUE
|
||||
}
|
||||
|
||||
// Automatically retry failed pages when subscribed to this page
|
||||
if (page.status == Page.State.ERROR) {
|
||||
page.status = Page.State.QUEUE
|
||||
}
|
||||
// Automatically retry failed pages when subscribed to this page
|
||||
if (page.status == Page.State.ERROR) {
|
||||
page.status = Page.State.QUEUE
|
||||
}
|
||||
|
||||
val queuedPages = mutableListOf<PriorityPage>()
|
||||
if (page.status == Page.State.QUEUE) {
|
||||
queuedPages += PriorityPage(page, 1).also { queue.offer(it) }
|
||||
}
|
||||
queuedPages += preloadNextPages(page, preloadSize)
|
||||
val queuedPages = mutableListOf<PriorityPage>()
|
||||
if (page.status == Page.State.QUEUE) {
|
||||
queuedPages += PriorityPage(page, 1).also { queue.offer(it) }
|
||||
}
|
||||
queuedPages += preloadNextPages(page, preloadSize)
|
||||
|
||||
suspendCancellableCoroutine<Nothing> { continuation ->
|
||||
continuation.invokeOnCancellation {
|
||||
queuedPages.forEach {
|
||||
if (it.page.status == Page.State.QUEUE) {
|
||||
queue.remove(it)
|
||||
}
|
||||
suspendCancellableCoroutine<Nothing> { continuation ->
|
||||
continuation.invokeOnCancellation {
|
||||
queuedPages.forEach {
|
||||
if (it.page.status == Page.State.QUEUE) {
|
||||
queue.remove(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -128,8 +124,7 @@ internal class HttpPageLoader(
|
|||
queue.clear()
|
||||
|
||||
// Cache current page list progress for online chapters to allow a faster reopen
|
||||
val pages = chapter.pages
|
||||
if (pages != null) {
|
||||
chapter.pages?.let { pages ->
|
||||
launchIO {
|
||||
try {
|
||||
// Convert to pages without reader information
|
||||
|
@ -171,7 +166,7 @@ internal class HttpPageLoader(
|
|||
*
|
||||
* @param page the page whose source image has to be downloaded.
|
||||
*/
|
||||
private suspend fun _loadPage(page: ReaderPage) {
|
||||
private suspend fun internalLoadPage(page: ReaderPage) {
|
||||
try {
|
||||
if (page.imageUrl.isNullOrEmpty()) {
|
||||
page.status = Page.State.LOAD_PAGE
|
||||
|
|
|
@ -3,13 +3,11 @@ package eu.kanade.tachiyomi.ui.reader.setting
|
|||
import cafe.adriel.voyager.core.model.ScreenModel
|
||||
import eu.kanade.presentation.util.ioCoroutineScope
|
||||
import eu.kanade.tachiyomi.ui.reader.ReaderViewModel
|
||||
import eu.kanade.tachiyomi.util.preference.toggle
|
||||
import kotlinx.coroutines.flow.SharingStarted
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlinx.coroutines.flow.distinctUntilChanged
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.flow.stateIn
|
||||
import tachiyomi.core.preference.Preference
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
||||
|
@ -29,8 +27,4 @@ class ReaderSettingsScreenModel(
|
|||
.map { it.manga }
|
||||
.distinctUntilChanged()
|
||||
.stateIn(ioCoroutineScope, SharingStarted.Lazily, null)
|
||||
|
||||
fun togglePreference(preference: (ReaderPreferences) -> Preference<Boolean>) {
|
||||
preference(preferences).toggle()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
package eu.kanade.tachiyomi.util.preference
|
||||
|
||||
import tachiyomi.core.preference.Preference
|
||||
|
||||
operator fun <T> Preference<Set<T>>.plusAssign(item: T) {
|
||||
set(get() + item)
|
||||
}
|
||||
|
||||
operator fun <T> Preference<Set<T>>.minusAssign(item: T) {
|
||||
set(get() - item)
|
||||
}
|
||||
|
||||
fun Preference<Boolean>.toggle(): Boolean {
|
||||
set(!get())
|
||||
return get()
|
||||
}
|
|
@ -24,3 +24,16 @@ interface Preference<T> {
|
|||
}
|
||||
|
||||
inline fun <reified T, R : T> Preference<T>.getAndSet(crossinline block: (T) -> R) = set(block(get()))
|
||||
|
||||
operator fun <T> Preference<Set<T>>.plusAssign(item: T) {
|
||||
set(get() + item)
|
||||
}
|
||||
|
||||
operator fun <T> Preference<Set<T>>.minusAssign(item: T) {
|
||||
set(get() - item)
|
||||
}
|
||||
|
||||
fun Preference<Boolean>.toggle(): Boolean {
|
||||
set(!get())
|
||||
return get()
|
||||
}
|
||||
|
|
|
@ -39,8 +39,11 @@ import androidx.compose.ui.Modifier
|
|||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import tachiyomi.core.preference.Preference
|
||||
import tachiyomi.core.preference.TriState
|
||||
import tachiyomi.core.preference.toggle
|
||||
import tachiyomi.presentation.core.theme.header
|
||||
import tachiyomi.presentation.core.util.collectAsState
|
||||
|
||||
object SettingsItemsPaddings {
|
||||
val Horizontal = 24.dp
|
||||
|
@ -118,6 +121,19 @@ fun SortItem(
|
|||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun CheckboxItem(
|
||||
label: String,
|
||||
pref: Preference<Boolean>,
|
||||
) {
|
||||
val checked by pref.collectAsState()
|
||||
CheckboxItem(
|
||||
label = label,
|
||||
checked = checked,
|
||||
onClick = { pref.toggle() },
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun CheckboxItem(
|
||||
label: String,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package eu.kanade.presentation.util
|
||||
package tachiyomi.presentation.core.util
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.State
|
Loading…
Reference in a new issue