mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
refactor: Split RecentsPreferences and UiPreferences from PreferencesHelper
This commit is contained in:
parent
0be92fecbe
commit
7dd56b1976
21 changed files with 112 additions and 60 deletions
|
@ -0,0 +1,18 @@
|
||||||
|
package dev.yokai.domain.recents
|
||||||
|
|
||||||
|
import eu.kanade.tachiyomi.core.preference.PreferenceStore
|
||||||
|
import eu.kanade.tachiyomi.core.preference.getEnum
|
||||||
|
import eu.kanade.tachiyomi.data.preference.PreferenceKeys
|
||||||
|
import eu.kanade.tachiyomi.ui.recents.RecentMangaAdapter
|
||||||
|
|
||||||
|
class RecentsPreferences(private val preferenceStore: PreferenceStore) {
|
||||||
|
fun showRecentsDownloads() =
|
||||||
|
preferenceStore.getEnum(PreferenceKeys.showDLsInRecents, RecentMangaAdapter.ShowRecentsDLs.All)
|
||||||
|
|
||||||
|
fun showRecentsRemHistory() = preferenceStore.getBoolean(PreferenceKeys.showRemHistoryInRecents, true)
|
||||||
|
|
||||||
|
fun showReadInAllRecents() = preferenceStore.getBoolean(PreferenceKeys.showReadInAllRecents, false)
|
||||||
|
|
||||||
|
fun showTitleFirstInRecents() =
|
||||||
|
preferenceStore.getBoolean(PreferenceKeys.showTitleFirstInRecents, false)
|
||||||
|
}
|
14
app/src/main/java/dev/yokai/domain/ui/UiPreferences.kt
Normal file
14
app/src/main/java/dev/yokai/domain/ui/UiPreferences.kt
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
package dev.yokai.domain.ui
|
||||||
|
|
||||||
|
import eu.kanade.tachiyomi.core.preference.PreferenceStore
|
||||||
|
import eu.kanade.tachiyomi.core.preference.getEnum
|
||||||
|
import eu.kanade.tachiyomi.data.preference.PreferenceKeys
|
||||||
|
import eu.kanade.tachiyomi.ui.recents.RecentMangaAdapter
|
||||||
|
|
||||||
|
class UiPreferences(private val preferenceStore: PreferenceStore) {
|
||||||
|
fun recentsViewType() = preferenceStore.getInt("recents_view_type", 0)
|
||||||
|
|
||||||
|
fun outlineOnCovers() = preferenceStore.getBoolean(PreferenceKeys.outlineOnCovers, true)
|
||||||
|
|
||||||
|
fun uniformGrid() = preferenceStore.getBoolean(PreferenceKeys.uniformGrid, true)
|
||||||
|
}
|
|
@ -264,10 +264,6 @@ class PreferencesHelper(val context: Context, val preferenceStore: PreferenceSto
|
||||||
|
|
||||||
fun gridSize() = preferenceStore.getFloat(Keys.gridSize, 1f)
|
fun gridSize() = preferenceStore.getFloat(Keys.gridSize, 1f)
|
||||||
|
|
||||||
fun uniformGrid() = preferenceStore.getBoolean(Keys.uniformGrid, true)
|
|
||||||
|
|
||||||
fun outlineOnCovers() = preferenceStore.getBoolean(Keys.outlineOnCovers, true)
|
|
||||||
|
|
||||||
fun downloadBadge() = preferenceStore.getBoolean(Keys.downloadBadge, false)
|
fun downloadBadge() = preferenceStore.getBoolean(Keys.downloadBadge, false)
|
||||||
|
|
||||||
fun languageBadge() = preferenceStore.getBoolean(Keys.languageBadge, false)
|
fun languageBadge() = preferenceStore.getBoolean(Keys.languageBadge, false)
|
||||||
|
@ -361,14 +357,6 @@ class PreferencesHelper(val context: Context, val preferenceStore: PreferenceSto
|
||||||
// TODO: SourcePref
|
// TODO: SourcePref
|
||||||
fun extensionUpdatesCount() = preferenceStore.getInt("ext_updates_count", 0)
|
fun extensionUpdatesCount() = preferenceStore.getInt("ext_updates_count", 0)
|
||||||
|
|
||||||
fun recentsViewType() = preferenceStore.getInt("recents_view_type", 0)
|
|
||||||
|
|
||||||
fun showRecentsDownloads() = preferenceStore.getEnum(Keys.showDLsInRecents, RecentMangaAdapter.ShowRecentsDLs.All)
|
|
||||||
|
|
||||||
fun showRecentsRemHistory() = preferenceStore.getBoolean(Keys.showRemHistoryInRecents, true)
|
|
||||||
|
|
||||||
fun showReadInAllRecents() = preferenceStore.getBoolean(Keys.showReadInAllRecents, false)
|
|
||||||
|
|
||||||
fun showUpdatedTime() = preferenceStore.getBoolean(Keys.showUpdatedTime, false)
|
fun showUpdatedTime() = preferenceStore.getBoolean(Keys.showUpdatedTime, false)
|
||||||
|
|
||||||
fun sortFetchedTime() = preferenceStore.getBoolean("sort_fetched_time", false)
|
fun sortFetchedTime() = preferenceStore.getBoolean("sort_fetched_time", false)
|
||||||
|
@ -379,8 +367,6 @@ class PreferencesHelper(val context: Context, val preferenceStore: PreferenceSto
|
||||||
|
|
||||||
fun collapseGroupedHistory() = preferenceStore.getBoolean("collapse_group_history", true)
|
fun collapseGroupedHistory() = preferenceStore.getBoolean("collapse_group_history", true)
|
||||||
|
|
||||||
fun showTitleFirstInRecents() = preferenceStore.getBoolean(Keys.showTitleFirstInRecents, false)
|
|
||||||
|
|
||||||
fun lastExtCheck() = preferenceStore.getLong("last_ext_check", 0)
|
fun lastExtCheck() = preferenceStore.getLong("last_ext_check", 0)
|
||||||
|
|
||||||
fun lastAppCheck() = preferenceStore.getLong("last_app_check", 0)
|
fun lastAppCheck() = preferenceStore.getLong("last_app_check", 0)
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
package eu.kanade.tachiyomi.di
|
package eu.kanade.tachiyomi.di
|
||||||
|
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
|
import dev.yokai.domain.recents.RecentsPreferences
|
||||||
import dev.yokai.domain.source.SourcePreferences
|
import dev.yokai.domain.source.SourcePreferences
|
||||||
|
import dev.yokai.domain.ui.UiPreferences
|
||||||
import eu.kanade.tachiyomi.core.preference.AndroidPreferenceStore
|
import eu.kanade.tachiyomi.core.preference.AndroidPreferenceStore
|
||||||
import eu.kanade.tachiyomi.core.preference.PreferenceStore
|
import eu.kanade.tachiyomi.core.preference.PreferenceStore
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
|
@ -19,6 +21,10 @@ class PreferenceModule(val application: Application) : InjektModule {
|
||||||
|
|
||||||
addSingletonFactory { TrackPreferences(get()) }
|
addSingletonFactory { TrackPreferences(get()) }
|
||||||
|
|
||||||
|
addSingletonFactory { UiPreferences(get()) }
|
||||||
|
|
||||||
|
addSingletonFactory { RecentsPreferences(get()) }
|
||||||
|
|
||||||
addSingletonFactory {
|
addSingletonFactory {
|
||||||
PreferencesHelper(
|
PreferencesHelper(
|
||||||
context = application,
|
context = application,
|
||||||
|
|
|
@ -358,7 +358,7 @@ class ExtensionBottomSheet @JvmOverloads constructor(context: Context, attrs: At
|
||||||
currentSourceTitle = title
|
currentSourceTitle = title
|
||||||
val changingAdapters = migAdapter !is MangaAdapter
|
val changingAdapters = migAdapter !is MangaAdapter
|
||||||
if (migAdapter !is MangaAdapter) {
|
if (migAdapter !is MangaAdapter) {
|
||||||
migAdapter = MangaAdapter(this, presenter.preferences.outlineOnCovers().get())
|
migAdapter = MangaAdapter(this, presenter.uiPreferences.outlineOnCovers().get())
|
||||||
migrationFrameLayout?.onBind(migAdapter!!)
|
migrationFrameLayout?.onBind(migAdapter!!)
|
||||||
migAdapter?.stateRestorationPolicy = RecyclerView.Adapter.StateRestorationPolicy.PREVENT_WHEN_EMPTY
|
migAdapter?.stateRestorationPolicy = RecyclerView.Adapter.StateRestorationPolicy.PREVENT_WHEN_EMPTY
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.ui.library
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.view.HapticFeedbackConstants
|
import android.view.HapticFeedbackConstants
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
import dev.yokai.domain.ui.UiPreferences
|
||||||
import eu.davidea.flexibleadapter.FlexibleAdapter
|
import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||||
import eu.davidea.flexibleadapter.items.IFlexible
|
import eu.davidea.flexibleadapter.items.IFlexible
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
|
@ -29,11 +30,12 @@ class LibraryCategoryAdapter(val controller: LibraryController?) :
|
||||||
|
|
||||||
val sourceManager by injectLazy<SourceManager>()
|
val sourceManager by injectLazy<SourceManager>()
|
||||||
|
|
||||||
|
private val uiPreferences: UiPreferences by injectLazy()
|
||||||
private val preferences: PreferencesHelper by injectLazy()
|
private val preferences: PreferencesHelper by injectLazy()
|
||||||
|
|
||||||
var showNumber = preferences.categoryNumberOfItems().get()
|
var showNumber = preferences.categoryNumberOfItems().get()
|
||||||
|
|
||||||
var showOutline = preferences.outlineOnCovers().get()
|
var showOutline = uiPreferences.outlineOnCovers().get()
|
||||||
|
|
||||||
private var lastCategory = ""
|
private var lastCategory = ""
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,7 @@ import com.bluelinelabs.conductor.ControllerChangeType
|
||||||
import com.github.florent37.viewtooltip.ViewTooltip
|
import com.github.florent37.viewtooltip.ViewTooltip
|
||||||
import com.google.android.material.snackbar.BaseTransientBottomBar
|
import com.google.android.material.snackbar.BaseTransientBottomBar
|
||||||
import com.google.android.material.snackbar.Snackbar
|
import com.google.android.material.snackbar.Snackbar
|
||||||
|
import dev.yokai.domain.ui.UiPreferences
|
||||||
import eu.davidea.flexibleadapter.FlexibleAdapter
|
import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||||
import eu.davidea.flexibleadapter.SelectableAdapter
|
import eu.davidea.flexibleadapter.SelectableAdapter
|
||||||
import eu.davidea.flexibleadapter.items.IFlexible
|
import eu.davidea.flexibleadapter.items.IFlexible
|
||||||
|
@ -138,6 +139,7 @@ import kotlin.random.nextInt
|
||||||
|
|
||||||
open class LibraryController(
|
open class LibraryController(
|
||||||
bundle: Bundle? = null,
|
bundle: Bundle? = null,
|
||||||
|
val uiPreferences: UiPreferences = Injekt.get(),
|
||||||
val preferences: PreferencesHelper = Injekt.get(),
|
val preferences: PreferencesHelper = Injekt.get(),
|
||||||
) : BaseCoroutineController<LibraryControllerBinding, LibraryPresenter>(bundle),
|
) : BaseCoroutineController<LibraryControllerBinding, LibraryPresenter>(bundle),
|
||||||
ActionMode.Callback,
|
ActionMode.Callback,
|
||||||
|
@ -968,7 +970,7 @@ open class LibraryController(
|
||||||
bottom = 50.dpToPx + (bottomNav?.height ?: 0),
|
bottom = 50.dpToPx + (bottomNav?.height ?: 0),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
useStaggered(preferences)
|
useStaggered(preferences, uiPreferences)
|
||||||
if (libraryLayout == LibraryItem.LAYOUT_LIST) {
|
if (libraryLayout == LibraryItem.LAYOUT_LIST) {
|
||||||
spanCount = 1
|
spanCount = 1
|
||||||
updatePaddingRelative(
|
updatePaddingRelative(
|
||||||
|
@ -999,7 +1001,7 @@ open class LibraryController(
|
||||||
private fun setPreferenceFlows() {
|
private fun setPreferenceFlows() {
|
||||||
listOf(
|
listOf(
|
||||||
preferences.libraryLayout(),
|
preferences.libraryLayout(),
|
||||||
preferences.uniformGrid(),
|
uiPreferences.uniformGrid(),
|
||||||
preferences.gridSize(),
|
preferences.gridSize(),
|
||||||
preferences.useStaggeredGrid(),
|
preferences.useStaggeredGrid(),
|
||||||
).forEach {
|
).forEach {
|
||||||
|
@ -1011,7 +1013,7 @@ open class LibraryController(
|
||||||
.launchIn(viewScope)
|
.launchIn(viewScope)
|
||||||
}
|
}
|
||||||
preferences.hideStartReadingButton().register()
|
preferences.hideStartReadingButton().register()
|
||||||
preferences.outlineOnCovers().register { adapter.showOutline = it }
|
uiPreferences.outlineOnCovers().register { adapter.showOutline = it }
|
||||||
preferences.categoryNumberOfItems().register { adapter.showNumber = it }
|
preferences.categoryNumberOfItems().register { adapter.showNumber = it }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ import androidx.core.view.isVisible
|
||||||
import androidx.core.view.updateLayoutParams
|
import androidx.core.view.updateLayoutParams
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import androidx.recyclerview.widget.StaggeredGridLayoutManager
|
import androidx.recyclerview.widget.StaggeredGridLayoutManager
|
||||||
|
import dev.yokai.domain.ui.UiPreferences
|
||||||
import eu.davidea.flexibleadapter.FlexibleAdapter
|
import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||||
import eu.davidea.flexibleadapter.items.AbstractSectionableItem
|
import eu.davidea.flexibleadapter.items.AbstractSectionableItem
|
||||||
import eu.davidea.flexibleadapter.items.IFilterable
|
import eu.davidea.flexibleadapter.items.IFilterable
|
||||||
|
@ -31,6 +32,7 @@ class LibraryItem(
|
||||||
val manga: LibraryManga,
|
val manga: LibraryManga,
|
||||||
header: LibraryHeaderItem,
|
header: LibraryHeaderItem,
|
||||||
private val context: Context?,
|
private val context: Context?,
|
||||||
|
private val uiPreferences: UiPreferences = Injekt.get(),
|
||||||
private val preferences: PreferencesHelper = Injekt.get(),
|
private val preferences: PreferencesHelper = Injekt.get(),
|
||||||
) : AbstractSectionableItem<LibraryHolder, LibraryHeaderItem>(header), IFilterable<String> {
|
) : AbstractSectionableItem<LibraryHolder, LibraryHeaderItem>(header), IFilterable<String> {
|
||||||
|
|
||||||
|
@ -41,7 +43,7 @@ class LibraryItem(
|
||||||
|
|
||||||
private val sourceManager: SourceManager by injectLazy()
|
private val sourceManager: SourceManager by injectLazy()
|
||||||
private val uniformSize: Boolean
|
private val uniformSize: Boolean
|
||||||
get() = preferences.uniformGrid().get()
|
get() = uiPreferences.uniformGrid().get()
|
||||||
|
|
||||||
private val libraryLayout: Int
|
private val libraryLayout: Int
|
||||||
get() = preferences.libraryLayout().get()
|
get() = preferences.libraryLayout().get()
|
||||||
|
|
|
@ -26,12 +26,12 @@ class LibraryDisplayView @JvmOverloads constructor(context: Context, attrs: Attr
|
||||||
override fun inflateBinding() = LibraryDisplayLayoutBinding.bind(this)
|
override fun inflateBinding() = LibraryDisplayLayoutBinding.bind(this)
|
||||||
override fun initGeneralPreferences() {
|
override fun initGeneralPreferences() {
|
||||||
binding.displayGroup.bindToPreference(preferences.libraryLayout())
|
binding.displayGroup.bindToPreference(preferences.libraryLayout())
|
||||||
binding.uniformGrid.bindToPreference(preferences.uniformGrid()) {
|
binding.uniformGrid.bindToPreference(uiPreferences.uniformGrid()) {
|
||||||
binding.staggeredGrid.isEnabled = !it
|
binding.staggeredGrid.isEnabled = !it
|
||||||
}
|
}
|
||||||
binding.outlineOnCovers.bindToPreference(preferences.outlineOnCovers())
|
binding.outlineOnCovers.bindToPreference(uiPreferences.outlineOnCovers())
|
||||||
binding.staggeredGrid.text = context.getString(R.string.use_staggered_grid).addBetaTag(context)
|
binding.staggeredGrid.text = context.getString(R.string.use_staggered_grid).addBetaTag(context)
|
||||||
binding.staggeredGrid.isEnabled = !preferences.uniformGrid().get()
|
binding.staggeredGrid.isEnabled = !uiPreferences.uniformGrid().get()
|
||||||
binding.staggeredGrid.bindToPreference(preferences.useStaggeredGrid())
|
binding.staggeredGrid.bindToPreference(preferences.useStaggeredGrid())
|
||||||
binding.gridSeekbar.value = ((preferences.gridSize().get() + .5f) * 2f).roundToInt().toFloat()
|
binding.gridSeekbar.value = ((preferences.gridSize().get() + .5f) * 2f).roundToInt().toFloat()
|
||||||
binding.resetGridSize.setOnClickListener {
|
binding.resetGridSize.setOnClickListener {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package eu.kanade.tachiyomi.ui.migration
|
package eu.kanade.tachiyomi.ui.migration
|
||||||
|
|
||||||
|
import dev.yokai.domain.ui.UiPreferences
|
||||||
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferenceValues
|
import eu.kanade.tachiyomi.data.preference.PreferenceValues
|
||||||
|
@ -21,6 +22,7 @@ import uy.kohesive.injekt.injectLazy
|
||||||
abstract class BaseMigrationPresenter<T : BaseMigrationInterface>(
|
abstract class BaseMigrationPresenter<T : BaseMigrationInterface>(
|
||||||
protected val sourceManager: SourceManager = Injekt.get(),
|
protected val sourceManager: SourceManager = Injekt.get(),
|
||||||
protected val db: DatabaseHelper = Injekt.get(),
|
protected val db: DatabaseHelper = Injekt.get(),
|
||||||
|
val uiPreferences: UiPreferences = Injekt.get(),
|
||||||
val preferences: PreferencesHelper = Injekt.get(),
|
val preferences: PreferencesHelper = Injekt.get(),
|
||||||
) : BaseCoroutinePresenter<T>() {
|
) : BaseCoroutinePresenter<T>() {
|
||||||
private var selectedSource: Pair<String, Long>? = null
|
private var selectedSource: Pair<String, Long>? = null
|
||||||
|
|
|
@ -139,7 +139,7 @@ class MigrationController :
|
||||||
override fun setMigrationManga(title: String, manga: List<MangaItem>?) {
|
override fun setMigrationManga(title: String, manga: List<MangaItem>?) {
|
||||||
this.title = title
|
this.title = title
|
||||||
if (adapter !is MangaAdapter) {
|
if (adapter !is MangaAdapter) {
|
||||||
adapter = MangaAdapter(this, presenter.preferences.outlineOnCovers().get())
|
adapter = MangaAdapter(this, presenter.uiPreferences.outlineOnCovers().get())
|
||||||
binding.migrationRecycler.adapter = adapter
|
binding.migrationRecycler.adapter = adapter
|
||||||
}
|
}
|
||||||
adapter?.updateDataSet(manga, true)
|
adapter?.updateDataSet(manga, true)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package eu.kanade.tachiyomi.ui.migration.manga.process
|
package eu.kanade.tachiyomi.ui.migration.manga.process
|
||||||
|
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
|
import dev.yokai.domain.ui.UiPreferences
|
||||||
import eu.davidea.flexibleadapter.FlexibleAdapter
|
import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||||
import eu.kanade.tachiyomi.data.cache.CoverCache
|
import eu.kanade.tachiyomi.data.cache.CoverCache
|
||||||
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
||||||
|
@ -31,11 +32,12 @@ class MigrationProcessAdapter(
|
||||||
private val db: DatabaseHelper by injectLazy()
|
private val db: DatabaseHelper by injectLazy()
|
||||||
var items: List<MigrationProcessItem> = emptyList()
|
var items: List<MigrationProcessItem> = emptyList()
|
||||||
val preferences: PreferencesHelper by injectLazy()
|
val preferences: PreferencesHelper by injectLazy()
|
||||||
|
val uiPreferences: UiPreferences by injectLazy()
|
||||||
val sourceManager: SourceManager by injectLazy()
|
val sourceManager: SourceManager by injectLazy()
|
||||||
val coverCache: CoverCache by injectLazy()
|
val coverCache: CoverCache by injectLazy()
|
||||||
val customMangaManager: CustomMangaManager by injectLazy()
|
val customMangaManager: CustomMangaManager by injectLazy()
|
||||||
|
|
||||||
var showOutline = preferences.outlineOnCovers().get()
|
var showOutline = uiPreferences.outlineOnCovers().get()
|
||||||
val menuItemListener: MigrationProcessInterface = controller
|
val menuItemListener: MigrationProcessInterface = controller
|
||||||
|
|
||||||
private val enhancedServices by lazy { Injekt.get<TrackManager>().services.filterIsInstance<EnhancedTrackService>() }
|
private val enhancedServices by lazy { Injekt.get<TrackManager>().services.filterIsInstance<EnhancedTrackService>() }
|
||||||
|
|
|
@ -2,6 +2,8 @@ package eu.kanade.tachiyomi.ui.recents
|
||||||
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.recyclerview.widget.ItemTouchHelper
|
import androidx.recyclerview.widget.ItemTouchHelper
|
||||||
|
import dev.yokai.domain.recents.RecentsPreferences
|
||||||
|
import dev.yokai.domain.ui.UiPreferences
|
||||||
import eu.davidea.flexibleadapter.items.IFlexible
|
import eu.davidea.flexibleadapter.items.IFlexible
|
||||||
import eu.kanade.tachiyomi.core.preference.Preference
|
import eu.kanade.tachiyomi.core.preference.Preference
|
||||||
import eu.kanade.tachiyomi.data.database.models.Chapter
|
import eu.kanade.tachiyomi.data.database.models.Chapter
|
||||||
|
@ -23,13 +25,15 @@ class RecentMangaAdapter(val delegate: RecentsInterface) :
|
||||||
BaseChapterAdapter<IFlexible<*>>(delegate) {
|
BaseChapterAdapter<IFlexible<*>>(delegate) {
|
||||||
|
|
||||||
val preferences: PreferencesHelper by injectLazy()
|
val preferences: PreferencesHelper by injectLazy()
|
||||||
|
val uiPreferences: UiPreferences by injectLazy()
|
||||||
|
val recentsPreferences: RecentsPreferences by injectLazy()
|
||||||
|
|
||||||
var showDownloads = preferences.showRecentsDownloads().get()
|
var showDownloads = recentsPreferences.showRecentsDownloads().get()
|
||||||
var showRemoveHistory = preferences.showRecentsRemHistory().get()
|
var showRemoveHistory = recentsPreferences.showRecentsRemHistory().get()
|
||||||
var showTitleFirst = preferences.showTitleFirstInRecents().get()
|
var showTitleFirst = recentsPreferences.showTitleFirstInRecents().get()
|
||||||
var showUpdatedTime = preferences.showUpdatedTime().get()
|
var showUpdatedTime = preferences.showUpdatedTime().get()
|
||||||
var uniformCovers = preferences.uniformGrid().get()
|
var uniformCovers = uiPreferences.uniformGrid().get()
|
||||||
var showOutline = preferences.outlineOnCovers().get()
|
var showOutline = uiPreferences.outlineOnCovers().get()
|
||||||
var sortByFetched = preferences.sortFetchedTime().get()
|
var sortByFetched = preferences.sortFetchedTime().get()
|
||||||
var lastUpdatedTime = preferences.libraryUpdateLastTimestamp().get()
|
var lastUpdatedTime = preferences.libraryUpdateLastTimestamp().get()
|
||||||
private var collapseGroupedUpdates = preferences.collapseGroupedUpdates().get()
|
private var collapseGroupedUpdates = preferences.collapseGroupedUpdates().get()
|
||||||
|
@ -56,15 +60,15 @@ class RecentMangaAdapter(val delegate: RecentsInterface) :
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setPreferenceFlows() {
|
fun setPreferenceFlows() {
|
||||||
preferences.showRecentsDownloads().register { showDownloads = it }
|
recentsPreferences.showRecentsDownloads().register { showDownloads = it }
|
||||||
preferences.showRecentsRemHistory().register { showRemoveHistory = it }
|
recentsPreferences.showRecentsRemHistory().register { showRemoveHistory = it }
|
||||||
preferences.showTitleFirstInRecents().register { showTitleFirst = it }
|
recentsPreferences.showTitleFirstInRecents().register { showTitleFirst = it }
|
||||||
preferences.showUpdatedTime().register { showUpdatedTime = it }
|
preferences.showUpdatedTime().register { showUpdatedTime = it }
|
||||||
preferences.uniformGrid().register { uniformCovers = it }
|
uiPreferences.uniformGrid().register { uniformCovers = it }
|
||||||
preferences.collapseGroupedUpdates().register { collapseGroupedUpdates = it }
|
preferences.collapseGroupedUpdates().register { collapseGroupedUpdates = it }
|
||||||
preferences.collapseGroupedHistory().register { collapseGroupedHistory = it }
|
preferences.collapseGroupedHistory().register { collapseGroupedHistory = it }
|
||||||
preferences.sortFetchedTime().changesIn(delegate.scope()) { sortByFetched = it }
|
preferences.sortFetchedTime().changesIn(delegate.scope()) { sortByFetched = it }
|
||||||
preferences.outlineOnCovers().register(false) {
|
uiPreferences.outlineOnCovers().register(false) {
|
||||||
showOutline = it
|
showOutline = it
|
||||||
(0 until itemCount).forEach { i ->
|
(0 until itemCount).forEach { i ->
|
||||||
(recyclerView.findViewHolderForAdapterPosition(i) as? RecentMangaHolder)?.updateCards()
|
(recyclerView.findViewHolderForAdapterPosition(i) as? RecentMangaHolder)?.updateCards()
|
||||||
|
|
|
@ -486,7 +486,7 @@ class RecentsController(bundle: Bundle? = null) :
|
||||||
|
|
||||||
override fun canStillGoBack(): Boolean {
|
override fun canStillGoBack(): Boolean {
|
||||||
return showingDownloads ||
|
return showingDownloads ||
|
||||||
presenter.preferences.recentsViewType().get() != presenter.viewType.mainValue
|
presenter.uiPreferences.recentsViewType().get() != presenter.viewType.mainValue
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun handleOnBackStarted(backEvent: BackEventCompat) {
|
override fun handleOnBackStarted(backEvent: BackEventCompat) {
|
||||||
|
@ -516,7 +516,7 @@ class RecentsController(bundle: Bundle? = null) :
|
||||||
binding.downloadBottomSheet.dlBottomSheet.dismiss()
|
binding.downloadBottomSheet.dlBottomSheet.dismiss()
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
val viewType = RecentsViewType.valueOf(presenter.preferences.recentsViewType().get())
|
val viewType = RecentsViewType.valueOf(presenter.uiPreferences.recentsViewType().get())
|
||||||
if (viewType != presenter.viewType) {
|
if (viewType != presenter.viewType) {
|
||||||
tempJumpTo(viewType)
|
tempJumpTo(viewType)
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package eu.kanade.tachiyomi.ui.recents
|
package eu.kanade.tachiyomi.ui.recents
|
||||||
|
|
||||||
|
import dev.yokai.domain.recents.RecentsPreferences
|
||||||
|
import dev.yokai.domain.ui.UiPreferences
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
||||||
import eu.kanade.tachiyomi.data.database.models.Chapter
|
import eu.kanade.tachiyomi.data.database.models.Chapter
|
||||||
|
@ -43,6 +45,8 @@ import kotlin.math.abs
|
||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
class RecentsPresenter(
|
class RecentsPresenter(
|
||||||
|
val uiPreferences: UiPreferences = Injekt.get(),
|
||||||
|
val recentsPreferences: RecentsPreferences = Injekt.get(),
|
||||||
val preferences: PreferencesHelper = Injekt.get(),
|
val preferences: PreferencesHelper = Injekt.get(),
|
||||||
val downloadManager: DownloadManager = Injekt.get(),
|
val downloadManager: DownloadManager = Injekt.get(),
|
||||||
val db: DatabaseHelper = Injekt.get(),
|
val db: DatabaseHelper = Injekt.get(),
|
||||||
|
@ -63,7 +67,7 @@ class RecentsPresenter(
|
||||||
RecentMangaHeaderItem(RecentMangaHeaderItem.CONTINUE_READING)
|
RecentMangaHeaderItem(RecentMangaHeaderItem.CONTINUE_READING)
|
||||||
var finished = false
|
var finished = false
|
||||||
private var shouldMoveToTop = false
|
private var shouldMoveToTop = false
|
||||||
var viewType: RecentsViewType = RecentsViewType.valueOf(preferences.recentsViewType().get())
|
var viewType: RecentsViewType = RecentsViewType.valueOf(uiPreferences.recentsViewType().get())
|
||||||
private set
|
private set
|
||||||
var groupHistory: GroupType = preferences.groupChaptersHistory().get()
|
var groupHistory: GroupType = preferences.groupChaptersHistory().get()
|
||||||
private set
|
private set
|
||||||
|
@ -98,7 +102,7 @@ class RecentsPresenter(
|
||||||
getRecents()
|
getRecents()
|
||||||
listOf(
|
listOf(
|
||||||
preferences.groupChaptersHistory(),
|
preferences.groupChaptersHistory(),
|
||||||
preferences.showReadInAllRecents(),
|
recentsPreferences.showReadInAllRecents(),
|
||||||
preferences.sortFetchedTime(),
|
preferences.sortFetchedTime(),
|
||||||
).forEach {
|
).forEach {
|
||||||
it.changes()
|
it.changes()
|
||||||
|
@ -152,7 +156,7 @@ class RecentsPresenter(
|
||||||
}
|
}
|
||||||
val viewType = customViewType ?: viewType
|
val viewType = customViewType ?: viewType
|
||||||
|
|
||||||
val showRead = ((preferences.showReadInAllRecents().get() || query.isNotEmpty()) && limit != 0) || includeReadAnyway
|
val showRead = ((recentsPreferences.showReadInAllRecents().get() || query.isNotEmpty()) && limit != 0) || includeReadAnyway
|
||||||
val isUngrouped = viewType != RecentsViewType.GroupedAll || query.isNotEmpty()
|
val isUngrouped = viewType != RecentsViewType.GroupedAll || query.isNotEmpty()
|
||||||
val groupChaptersHistory = preferences.groupChaptersHistory().get()
|
val groupChaptersHistory = preferences.groupChaptersHistory().get()
|
||||||
groupHistory = groupChaptersHistory
|
groupHistory = groupChaptersHistory
|
||||||
|
@ -469,7 +473,7 @@ class RecentsPresenter(
|
||||||
|
|
||||||
fun toggleGroupRecents(pref: RecentsViewType, updatePref: Boolean = true) {
|
fun toggleGroupRecents(pref: RecentsViewType, updatePref: Boolean = true) {
|
||||||
if (updatePref) {
|
if (updatePref) {
|
||||||
preferences.recentsViewType().set(pref.mainValue)
|
uiPreferences.recentsViewType().set(pref.mainValue)
|
||||||
}
|
}
|
||||||
viewType = pref
|
viewType = pref
|
||||||
resetOffsets()
|
resetOffsets()
|
||||||
|
|
|
@ -19,11 +19,11 @@ class RecentsGeneralView @JvmOverloads constructor(context: Context, attrs: Attr
|
||||||
.withSubtitle(binding.showRemoveHistory.context, R.string.press_and_hold_to_also_reset)
|
.withSubtitle(binding.showRemoveHistory.context, R.string.press_and_hold_to_also_reset)
|
||||||
binding.uniformCovers.text = uniformText
|
binding.uniformCovers.text = uniformText
|
||||||
.withSubtitle(binding.uniformCovers.context, R.string.affects_library_grid)
|
.withSubtitle(binding.uniformCovers.context, R.string.affects_library_grid)
|
||||||
binding.showRecentsDownload.bindToPreference(preferences.showRecentsDownloads())
|
binding.showRecentsDownload.bindToPreference(recentsPreferences.showRecentsDownloads())
|
||||||
binding.showRemoveHistory.bindToPreference(preferences.showRecentsRemHistory())
|
binding.showRemoveHistory.bindToPreference(recentsPreferences.showRecentsRemHistory())
|
||||||
binding.showReadInAll.bindToPreference(preferences.showReadInAllRecents())
|
binding.showReadInAll.bindToPreference(recentsPreferences.showReadInAllRecents())
|
||||||
binding.showTitleFirst.bindToPreference(preferences.showTitleFirstInRecents())
|
binding.showTitleFirst.bindToPreference(recentsPreferences.showTitleFirstInRecents())
|
||||||
binding.uniformCovers.bindToPreference(preferences.uniformGrid())
|
binding.uniformCovers.bindToPreference(uiPreferences.uniformGrid())
|
||||||
binding.outlineOnCovers.bindToPreference(preferences.outlineOnCovers())
|
binding.outlineOnCovers.bindToPreference(uiPreferences.outlineOnCovers())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -206,7 +206,7 @@ open class BrowseSourceController(bundle: Bundle) :
|
||||||
binding.catalogueView.removeView(oldRecycler)
|
binding.catalogueView.removeView(oldRecycler)
|
||||||
}
|
}
|
||||||
|
|
||||||
val recycler = if (presenter.prefs.browseAsList().get()) {
|
val recycler = if (presenter.preferences.browseAsList().get()) {
|
||||||
RecyclerView(view.context).apply {
|
RecyclerView(view.context).apply {
|
||||||
id = R.id.recycler
|
id = R.id.recycler
|
||||||
layoutManager = LinearLayoutManagerAccurateOffset(context)
|
layoutManager = LinearLayoutManagerAccurateOffset(context)
|
||||||
|
@ -320,7 +320,7 @@ open class BrowseSourceController(bundle: Bundle) :
|
||||||
|
|
||||||
private fun updateDisplayMenuItem(menu: Menu?, isListMode: Boolean? = null) {
|
private fun updateDisplayMenuItem(menu: Menu?, isListMode: Boolean? = null) {
|
||||||
menu?.findItem(R.id.action_display_mode)?.apply {
|
menu?.findItem(R.id.action_display_mode)?.apply {
|
||||||
val icon = if (isListMode ?: presenter.prefs.browseAsList().get()) {
|
val icon = if (isListMode ?: presenter.preferences.browseAsList().get()) {
|
||||||
R.drawable.ic_view_module_24dp
|
R.drawable.ic_view_module_24dp
|
||||||
} else {
|
} else {
|
||||||
R.drawable.ic_view_list_24dp
|
R.drawable.ic_view_list_24dp
|
||||||
|
@ -663,8 +663,8 @@ open class BrowseSourceController(bundle: Bundle) :
|
||||||
val view = view ?: return
|
val view = view ?: return
|
||||||
val adapter = adapter ?: return
|
val adapter = adapter ?: return
|
||||||
|
|
||||||
val isListMode = !presenter.prefs.browseAsList().get()
|
val isListMode = !presenter.preferences.browseAsList().get()
|
||||||
presenter.prefs.browseAsList().set(isListMode)
|
presenter.preferences.browseAsList().set(isListMode)
|
||||||
listOf(activityBinding?.toolbar?.menu, activityBinding?.searchToolbar?.menu).forEach {
|
listOf(activityBinding?.toolbar?.menu, activityBinding?.searchToolbar?.menu).forEach {
|
||||||
updateDisplayMenuItem(it, isListMode)
|
updateDisplayMenuItem(it, isListMode)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package eu.kanade.tachiyomi.ui.source.browse
|
package eu.kanade.tachiyomi.ui.source.browse
|
||||||
|
|
||||||
|
import dev.yokai.domain.ui.UiPreferences
|
||||||
import eu.davidea.flexibleadapter.items.IFlexible
|
import eu.davidea.flexibleadapter.items.IFlexible
|
||||||
import eu.kanade.tachiyomi.data.cache.CoverCache
|
import eu.kanade.tachiyomi.data.cache.CoverCache
|
||||||
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
||||||
|
@ -48,7 +49,8 @@ open class BrowseSourcePresenter(
|
||||||
var useLatest: Boolean = false,
|
var useLatest: Boolean = false,
|
||||||
val sourceManager: SourceManager = Injekt.get(),
|
val sourceManager: SourceManager = Injekt.get(),
|
||||||
val db: DatabaseHelper = Injekt.get(),
|
val db: DatabaseHelper = Injekt.get(),
|
||||||
val prefs: PreferencesHelper = Injekt.get(),
|
val uiPreferences: UiPreferences = Injekt.get(),
|
||||||
|
val preferences: PreferencesHelper = Injekt.get(),
|
||||||
private val coverCache: CoverCache = Injekt.get(),
|
private val coverCache: CoverCache = Injekt.get(),
|
||||||
) : BaseCoroutinePresenter<BrowseSourceController>() {
|
) : BaseCoroutinePresenter<BrowseSourceController>() {
|
||||||
|
|
||||||
|
@ -159,9 +161,9 @@ open class BrowseSourcePresenter(
|
||||||
|
|
||||||
val sourceId = source.id
|
val sourceId = source.id
|
||||||
|
|
||||||
val browseAsList = prefs.browseAsList()
|
val browseAsList = preferences.browseAsList()
|
||||||
val sourceListType = prefs.libraryLayout()
|
val sourceListType = preferences.libraryLayout()
|
||||||
val outlineCovers = prefs.outlineOnCovers()
|
val outlineCovers = uiPreferences.outlineOnCovers()
|
||||||
items.clear()
|
items.clear()
|
||||||
|
|
||||||
// Prepare the pager.
|
// Prepare the pager.
|
||||||
|
@ -171,7 +173,7 @@ open class BrowseSourcePresenter(
|
||||||
try {
|
try {
|
||||||
val mangas = second
|
val mangas = second
|
||||||
.map { networkToLocalManga(it, sourceId) }
|
.map { networkToLocalManga(it, sourceId) }
|
||||||
.filter { !prefs.hideInLibraryItems().get() || !it.favorite }
|
.filter { !preferences.hideInLibraryItems().get() || !it.favorite }
|
||||||
if (mangas.isEmpty() && page == 1) {
|
if (mangas.isEmpty() && page == 1) {
|
||||||
withUIContext { view?.onAddPageError(NoResultsException()) }
|
withUIContext { view?.onAddPageError(NoResultsException()) }
|
||||||
return@onEach
|
return@onEach
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package eu.kanade.tachiyomi.ui.source.globalsearch
|
package eu.kanade.tachiyomi.ui.source.globalsearch
|
||||||
|
|
||||||
|
import dev.yokai.domain.ui.UiPreferences
|
||||||
import eu.davidea.flexibleadapter.FlexibleAdapter
|
import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
|
@ -17,8 +18,9 @@ class GlobalSearchCardAdapter(controller: GlobalSearchController) :
|
||||||
* Listen for browse item clicks.
|
* Listen for browse item clicks.
|
||||||
*/
|
*/
|
||||||
val mangaClickListener: OnMangaClickListener = controller
|
val mangaClickListener: OnMangaClickListener = controller
|
||||||
|
private val uiPreferences: UiPreferences by injectLazy()
|
||||||
private val preferences: PreferencesHelper by injectLazy()
|
private val preferences: PreferencesHelper by injectLazy()
|
||||||
val showOutlines = preferences.outlineOnCovers().get()
|
val showOutlines = uiPreferences.outlineOnCovers().get()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Listener which should be called when user clicks browse.
|
* Listener which should be called when user clicks browse.
|
||||||
|
|
|
@ -9,6 +9,7 @@ import androidx.preference.PreferenceManager
|
||||||
import androidx.recyclerview.widget.GridLayoutManager
|
import androidx.recyclerview.widget.GridLayoutManager
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import androidx.recyclerview.widget.StaggeredGridLayoutManager
|
import androidx.recyclerview.widget.StaggeredGridLayoutManager
|
||||||
|
import dev.yokai.domain.ui.UiPreferences
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.ui.library.LibraryItem
|
import eu.kanade.tachiyomi.ui.library.LibraryItem
|
||||||
import eu.kanade.tachiyomi.util.system.dpToPx
|
import eu.kanade.tachiyomi.util.system.dpToPx
|
||||||
|
@ -85,10 +86,10 @@ class AutofitRecyclerView @JvmOverloads constructor(context: Context, attrs: Att
|
||||||
lastMeasuredWidth = width
|
lastMeasuredWidth = width
|
||||||
}
|
}
|
||||||
|
|
||||||
fun useStaggered(preferences: PreferencesHelper) {
|
fun useStaggered(preferences: PreferencesHelper, uiPreferences: UiPreferences) {
|
||||||
useStaggered(
|
useStaggered(
|
||||||
preferences.useStaggeredGrid().get() &&
|
preferences.useStaggeredGrid().get() &&
|
||||||
!preferences.uniformGrid().get() &&
|
!uiPreferences.uniformGrid().get() &&
|
||||||
preferences.libraryLayout().get() != LibraryItem.LAYOUT_LIST,
|
preferences.libraryLayout().get() != LibraryItem.LAYOUT_LIST,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,8 @@ import android.content.Context
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import androidx.core.widget.NestedScrollView
|
import androidx.core.widget.NestedScrollView
|
||||||
import androidx.viewbinding.ViewBinding
|
import androidx.viewbinding.ViewBinding
|
||||||
|
import dev.yokai.domain.recents.RecentsPreferences
|
||||||
|
import dev.yokai.domain.ui.UiPreferences
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.ui.library.LibraryController
|
import eu.kanade.tachiyomi.ui.library.LibraryController
|
||||||
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
|
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
|
||||||
|
@ -19,7 +21,8 @@ abstract class BaseTabbedScrollView<VB : ViewBinding> @JvmOverloads constructor(
|
||||||
init {
|
init {
|
||||||
clipToPadding = false
|
clipToPadding = false
|
||||||
}
|
}
|
||||||
internal val preferences by injectLazy<PreferencesHelper>()
|
internal val preferences: PreferencesHelper by injectLazy()
|
||||||
|
internal val uiPreferences: UiPreferences by injectLazy()
|
||||||
|
|
||||||
abstract fun initGeneralPreferences()
|
abstract fun initGeneralPreferences()
|
||||||
abstract fun inflateBinding(): VB
|
abstract fun inflateBinding(): VB
|
||||||
|
@ -35,6 +38,8 @@ abstract class BaseTabbedScrollView<VB : ViewBinding> @JvmOverloads constructor(
|
||||||
abstract class BaseRecentsDisplayView<VB : ViewBinding> @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
|
abstract class BaseRecentsDisplayView<VB : ViewBinding> @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
|
||||||
BaseTabbedScrollView<VB>(context, attrs) {
|
BaseTabbedScrollView<VB>(context, attrs) {
|
||||||
var controller: RecentsController? = null
|
var controller: RecentsController? = null
|
||||||
|
|
||||||
|
internal val recentsPreferences: RecentsPreferences by injectLazy()
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class BaseLibraryDisplayView<VB : ViewBinding> @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
|
abstract class BaseLibraryDisplayView<VB : ViewBinding> @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue