Minor cleanup
# Conflicts: # app/src/main/java/eu/kanade/presentation/browse/ExtensionsScreen.kt # app/src/main/java/eu/kanade/tachiyomi/ui/browse/BrowseController.kt # app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourcesController.kt # app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourcesPresenter.kt
This commit is contained in:
parent
4458f74f6c
commit
1c86a7c94b
@ -1,7 +1,7 @@
|
|||||||
package eu.kanade.domain.source.interactor
|
package eu.kanade.domain.source.interactor
|
||||||
|
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.ui.browse.source.SourceController
|
import eu.kanade.tachiyomi.ui.browse.source.SourcesController
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlinx.coroutines.flow.map
|
import kotlinx.coroutines.flow.map
|
||||||
|
|
||||||
@ -9,10 +9,10 @@ class GetShowLatest(
|
|||||||
private val preferences: PreferencesHelper,
|
private val preferences: PreferencesHelper,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
fun subscribe(mode: SourceController.Mode): Flow<Boolean> {
|
fun subscribe(mode: SourcesController.Mode): Flow<Boolean> {
|
||||||
return preferences.useNewSourceNavigation().asFlow()
|
return preferences.useNewSourceNavigation().asFlow()
|
||||||
.map {
|
.map {
|
||||||
mode == SourceController.Mode.CATALOGUE && !it
|
mode == SourcesController.Mode.CATALOGUE && !it
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package eu.kanade.presentation.extension
|
package eu.kanade.presentation.browse
|
||||||
|
|
||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
import androidx.compose.foundation.combinedClickable
|
import androidx.compose.foundation.combinedClickable
|
||||||
@ -49,16 +49,16 @@ import eu.kanade.tachiyomi.R
|
|||||||
import eu.kanade.tachiyomi.extension.model.Extension
|
import eu.kanade.tachiyomi.extension.model.Extension
|
||||||
import eu.kanade.tachiyomi.extension.model.InstallStep
|
import eu.kanade.tachiyomi.extension.model.InstallStep
|
||||||
import eu.kanade.tachiyomi.source.ConfigurableSource
|
import eu.kanade.tachiyomi.source.ConfigurableSource
|
||||||
import eu.kanade.tachiyomi.ui.browse.extension.ExtensionPresenter
|
|
||||||
import eu.kanade.tachiyomi.ui.browse.extension.ExtensionState
|
import eu.kanade.tachiyomi.ui.browse.extension.ExtensionState
|
||||||
import eu.kanade.tachiyomi.ui.browse.extension.ExtensionUiModel
|
import eu.kanade.tachiyomi.ui.browse.extension.ExtensionUiModel
|
||||||
|
import eu.kanade.tachiyomi.ui.browse.extension.ExtensionsPresenter
|
||||||
import eu.kanade.tachiyomi.util.system.LocaleHelper
|
import eu.kanade.tachiyomi.util.system.LocaleHelper
|
||||||
import exh.source.anyIs
|
import exh.source.anyIs
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun ExtensionScreen(
|
fun ExtensionScreen(
|
||||||
nestedScrollInterop: NestedScrollConnection,
|
nestedScrollInterop: NestedScrollConnection,
|
||||||
presenter: ExtensionPresenter,
|
presenter: ExtensionsPresenter,
|
||||||
onLongClickItem: (Extension) -> Unit,
|
onLongClickItem: (Extension) -> Unit,
|
||||||
onClickItemCancel: (Extension) -> Unit,
|
onClickItemCancel: (Extension) -> Unit,
|
||||||
onInstallExtension: (Extension.Available) -> Unit,
|
onInstallExtension: (Extension.Available) -> Unit,
|
||||||
@ -115,6 +115,7 @@ fun ExtensionContent(
|
|||||||
) {
|
) {
|
||||||
val (trustState, setTrustState) = remember { mutableStateOf<Extension.Untrusted?>(null) }
|
val (trustState, setTrustState) = remember { mutableStateOf<Extension.Untrusted?>(null) }
|
||||||
LazyColumn(
|
LazyColumn(
|
||||||
|
modifier = Modifier.nestedScroll(nestedScrollInterop),
|
||||||
contentPadding = WindowInsets.navigationBars.asPaddingValues() + topPaddingValues,
|
contentPadding = WindowInsets.navigationBars.asPaddingValues() + topPaddingValues,
|
||||||
) {
|
) {
|
||||||
items(
|
items(
|
@ -44,14 +44,14 @@ import eu.kanade.presentation.util.plus
|
|||||||
import eu.kanade.presentation.util.topPaddingValues
|
import eu.kanade.presentation.util.topPaddingValues
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.source.LocalSource
|
import eu.kanade.tachiyomi.source.LocalSource
|
||||||
import eu.kanade.tachiyomi.ui.browse.source.SourcePresenter
|
|
||||||
import eu.kanade.tachiyomi.ui.browse.source.SourceState
|
import eu.kanade.tachiyomi.ui.browse.source.SourceState
|
||||||
|
import eu.kanade.tachiyomi.ui.browse.source.SourcesPresenter
|
||||||
import eu.kanade.tachiyomi.util.system.LocaleHelper
|
import eu.kanade.tachiyomi.util.system.LocaleHelper
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun SourceScreen(
|
fun SourcesScreen(
|
||||||
nestedScrollInterop: NestedScrollConnection,
|
nestedScrollInterop: NestedScrollConnection,
|
||||||
presenter: SourcePresenter,
|
presenter: SourcesPresenter,
|
||||||
onClickItem: (Source) -> Unit,
|
onClickItem: (Source) -> Unit,
|
||||||
onClickDisable: (Source) -> Unit,
|
onClickDisable: (Source) -> Unit,
|
||||||
onClickLatest: (Source) -> Unit,
|
onClickLatest: (Source) -> Unit,
|
||||||
@ -104,8 +104,7 @@ fun SourceList(
|
|||||||
val (sourceCategoriesState, setSourceCategoriesState) = remember { mutableStateOf<Source?>(null) }
|
val (sourceCategoriesState, setSourceCategoriesState) = remember { mutableStateOf<Source?>(null) }
|
||||||
// SY <--
|
// SY <--
|
||||||
LazyColumn(
|
LazyColumn(
|
||||||
modifier = Modifier
|
modifier = Modifier.nestedScroll(nestedScrollConnection),
|
||||||
.nestedScroll(nestedScrollConnection),
|
|
||||||
contentPadding = WindowInsets.navigationBars.asPaddingValues() + topPaddingValues,
|
contentPadding = WindowInsets.navigationBars.asPaddingValues() + topPaddingValues,
|
||||||
) {
|
) {
|
||||||
items(
|
items(
|
@ -76,7 +76,7 @@ import java.text.SimpleDateFormat
|
|||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
import kotlin.time.Duration.Companion.days
|
import kotlin.time.Duration.Companion.days
|
||||||
|
|
||||||
open class App : Application(), DefaultLifecycleObserver, ImageLoaderFactory {
|
class App : Application(), DefaultLifecycleObserver, ImageLoaderFactory {
|
||||||
|
|
||||||
private val preferences: PreferencesHelper by injectLazy()
|
private val preferences: PreferencesHelper by injectLazy()
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ class AppModule(val app: Application) : InjektModule {
|
|||||||
|
|
||||||
addSingletonFactory { PreferencesHelper(app) }
|
addSingletonFactory { PreferencesHelper(app) }
|
||||||
|
|
||||||
addSingletonFactory { DatabaseHelper(app, get()) }
|
addSingletonFactory { DatabaseHelper(get()) }
|
||||||
|
|
||||||
addSingletonFactory { ChapterCache(app) }
|
addSingletonFactory { ChapterCache(app) }
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package eu.kanade.tachiyomi.data.database
|
package eu.kanade.tachiyomi.data.database
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import androidx.sqlite.db.SupportSQLiteOpenHelper
|
import androidx.sqlite.db.SupportSQLiteOpenHelper
|
||||||
import com.pushtorefresh.storio.sqlite.impl.DefaultStorIOSQLite
|
import com.pushtorefresh.storio.sqlite.impl.DefaultStorIOSQLite
|
||||||
import eu.kanade.tachiyomi.data.database.mappers.CategoryTypeMapping
|
import eu.kanade.tachiyomi.data.database.mappers.CategoryTypeMapping
|
||||||
@ -44,8 +43,7 @@ import exh.savedsearches.models.SavedSearch
|
|||||||
/**
|
/**
|
||||||
* This class provides operations to manage the database through its interfaces.
|
* This class provides operations to manage the database through its interfaces.
|
||||||
*/
|
*/
|
||||||
open class DatabaseHelper(
|
class DatabaseHelper(
|
||||||
context: Context,
|
|
||||||
openHelper: SupportSQLiteOpenHelper,
|
openHelper: SupportSQLiteOpenHelper,
|
||||||
) :
|
) :
|
||||||
MangaQueries,
|
MangaQueries,
|
||||||
|
@ -11,8 +11,8 @@ import eu.kanade.tachiyomi.network.NetworkHelper
|
|||||||
import eu.kanade.tachiyomi.network.await
|
import eu.kanade.tachiyomi.network.await
|
||||||
import eu.kanade.tachiyomi.network.parseAs
|
import eu.kanade.tachiyomi.network.parseAs
|
||||||
import eu.kanade.tachiyomi.util.lang.withIOContext
|
import eu.kanade.tachiyomi.util.lang.withIOContext
|
||||||
import exh.source.BlacklistedSources
|
|
||||||
import eu.kanade.tachiyomi.util.system.logcat
|
import eu.kanade.tachiyomi.util.system.logcat
|
||||||
|
import exh.source.BlacklistedSources
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import logcat.LogPriority
|
import logcat.LogPriority
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
@ -107,7 +107,7 @@ internal class ExtensionGithubApi {
|
|||||||
private fun List<ExtensionJsonObject>.toExtensions(
|
private fun List<ExtensionJsonObject>.toExtensions(
|
||||||
// SY -->
|
// SY -->
|
||||||
repoUrl: String = getUrlPrefix(),
|
repoUrl: String = getUrlPrefix(),
|
||||||
repoSource: Boolean = false
|
repoSource: Boolean = false,
|
||||||
// SY <--
|
// SY <--
|
||||||
): List<Extension.Available> {
|
): List<Extension.Available> {
|
||||||
return this
|
return this
|
||||||
@ -130,7 +130,7 @@ internal class ExtensionGithubApi {
|
|||||||
iconUrl = "${/* SY --> */ repoUrl /* SY <-- */}icon/${it.apk.replace(".apk", ".png")}",
|
iconUrl = "${/* SY --> */ repoUrl /* SY <-- */}icon/${it.apk.replace(".apk", ".png")}",
|
||||||
// SY -->
|
// SY -->
|
||||||
repoUrl = repoUrl,
|
repoUrl = repoUrl,
|
||||||
isRepoSource = repoSource
|
isRepoSource = repoSource,
|
||||||
// SY <--
|
// SY <--
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ import tachiyomi.source.model.MangaInfo
|
|||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
import kotlin.reflect.KClass
|
import kotlin.reflect.KClass
|
||||||
|
|
||||||
open class SourceManager(private val context: Context) {
|
class SourceManager(private val context: Context) {
|
||||||
|
|
||||||
private val sourcesMap = mutableMapOf<Long, Source>()
|
private val sourcesMap = mutableMapOf<Long, Source>()
|
||||||
private val stubSourcesMap = mutableMapOf<Long, StubSource>()
|
private val stubSourcesMap = mutableMapOf<Long, StubSource>()
|
||||||
@ -84,7 +84,7 @@ open class SourceManager(private val context: Context) {
|
|||||||
// SY <--
|
// SY <--
|
||||||
}
|
}
|
||||||
|
|
||||||
open fun get(sourceKey: Long): Source? {
|
fun get(sourceKey: Long): Source? {
|
||||||
return sourcesMap[sourceKey]
|
return sourcesMap[sourceKey]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,10 +19,10 @@ import eu.kanade.tachiyomi.databinding.PagerControllerBinding
|
|||||||
import eu.kanade.tachiyomi.ui.base.controller.RootController
|
import eu.kanade.tachiyomi.ui.base.controller.RootController
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.RxController
|
import eu.kanade.tachiyomi.ui.base.controller.RxController
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.TabbedController
|
import eu.kanade.tachiyomi.ui.base.controller.TabbedController
|
||||||
import eu.kanade.tachiyomi.ui.browse.extension.ExtensionController
|
import eu.kanade.tachiyomi.ui.browse.extension.ExtensionsController
|
||||||
import eu.kanade.tachiyomi.ui.browse.feed.FeedController
|
import eu.kanade.tachiyomi.ui.browse.feed.FeedController
|
||||||
import eu.kanade.tachiyomi.ui.browse.migration.sources.MigrationSourcesController
|
import eu.kanade.tachiyomi.ui.browse.migration.sources.MigrationSourcesController
|
||||||
import eu.kanade.tachiyomi.ui.browse.source.SourceController
|
import eu.kanade.tachiyomi.ui.browse.source.SourcesController
|
||||||
import eu.kanade.tachiyomi.ui.main.MainActivity
|
import eu.kanade.tachiyomi.ui.main.MainActivity
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
|
|
||||||
@ -144,10 +144,10 @@ class BrowseController :
|
|||||||
if (!router.hasRootController()) {
|
if (!router.hasRootController()) {
|
||||||
val controller: Controller = when (position) {
|
val controller: Controller = when (position) {
|
||||||
// SY -->
|
// SY -->
|
||||||
SOURCES_CONTROLLER -> if (preferences.feedTabInFront().get()) FeedController() else SourceController()
|
SOURCES_CONTROLLER -> if (preferences.feedTabInFront().get()) FeedController() else SourcesController()
|
||||||
FEED_CONTROLLER -> if (!preferences.feedTabInFront().get()) FeedController() else SourceController()
|
FEED_CONTROLLER -> if (!preferences.feedTabInFront().get()) FeedController() else SourcesController()
|
||||||
// SY <--
|
// SY <--
|
||||||
EXTENSIONS_CONTROLLER -> ExtensionController()
|
EXTENSIONS_CONTROLLER -> ExtensionsController()
|
||||||
MIGRATION_CONTROLLER -> MigrationSourcesController()
|
MIGRATION_CONTROLLER -> MigrationSourcesController()
|
||||||
else -> error("Wrong position $position")
|
else -> error("Wrong position $position")
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ import androidx.compose.runtime.Composable
|
|||||||
import androidx.compose.ui.input.nestedscroll.NestedScrollConnection
|
import androidx.compose.ui.input.nestedscroll.NestedScrollConnection
|
||||||
import com.bluelinelabs.conductor.ControllerChangeHandler
|
import com.bluelinelabs.conductor.ControllerChangeHandler
|
||||||
import com.bluelinelabs.conductor.ControllerChangeType
|
import com.bluelinelabs.conductor.ControllerChangeType
|
||||||
import eu.kanade.presentation.extension.ExtensionScreen
|
import eu.kanade.presentation.browse.ExtensionScreen
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.extension.model.Extension
|
import eu.kanade.tachiyomi.extension.model.Extension
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.ComposeController
|
import eu.kanade.tachiyomi.ui.base.controller.ComposeController
|
||||||
@ -20,11 +20,7 @@ import kotlinx.coroutines.flow.launchIn
|
|||||||
import kotlinx.coroutines.flow.onEach
|
import kotlinx.coroutines.flow.onEach
|
||||||
import reactivecircus.flowbinding.appcompat.queryTextChanges
|
import reactivecircus.flowbinding.appcompat.queryTextChanges
|
||||||
|
|
||||||
/**
|
class ExtensionsController : ComposeController<ExtensionsPresenter>() {
|
||||||
* Controller to manage the catalogues available in the app.
|
|
||||||
*/
|
|
||||||
open class ExtensionController :
|
|
||||||
ComposeController<ExtensionPresenter>() {
|
|
||||||
|
|
||||||
private var query = ""
|
private var query = ""
|
||||||
|
|
||||||
@ -32,11 +28,9 @@ open class ExtensionController :
|
|||||||
setHasOptionsMenu(true)
|
setHasOptionsMenu(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getTitle(): String? =
|
override fun getTitle() = applicationContext?.getString(R.string.label_extensions)
|
||||||
applicationContext?.getString(R.string.label_extensions)
|
|
||||||
|
|
||||||
override fun createPresenter(): ExtensionPresenter =
|
override fun createPresenter() = ExtensionsPresenter()
|
||||||
ExtensionPresenter()
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
override fun ComposeContent(nestedScrollInterop: NestedScrollConnection) {
|
override fun ComposeContent(nestedScrollInterop: NestedScrollConnection) {
|
@ -26,14 +26,11 @@ import rx.Observable
|
|||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
import uy.kohesive.injekt.api.get
|
import uy.kohesive.injekt.api.get
|
||||||
|
|
||||||
/**
|
class ExtensionsPresenter(
|
||||||
* Presenter of [ExtensionController].
|
|
||||||
*/
|
|
||||||
open class ExtensionPresenter(
|
|
||||||
private val extensionManager: ExtensionManager = Injekt.get(),
|
private val extensionManager: ExtensionManager = Injekt.get(),
|
||||||
private val getExtensionUpdates: GetExtensionUpdates = Injekt.get(),
|
private val getExtensionUpdates: GetExtensionUpdates = Injekt.get(),
|
||||||
private val getExtensions: GetExtensions = Injekt.get(),
|
private val getExtensions: GetExtensions = Injekt.get(),
|
||||||
) : BasePresenter<ExtensionController>() {
|
) : BasePresenter<ExtensionsController>() {
|
||||||
|
|
||||||
private val _query: MutableStateFlow<String> = MutableStateFlow("")
|
private val _query: MutableStateFlow<String> = MutableStateFlow("")
|
||||||
|
|
@ -13,7 +13,7 @@ import androidx.compose.ui.input.nestedscroll.NestedScrollConnection
|
|||||||
import androidx.core.os.bundleOf
|
import androidx.core.os.bundleOf
|
||||||
import com.bluelinelabs.conductor.Controller
|
import com.bluelinelabs.conductor.Controller
|
||||||
import eu.kanade.domain.source.model.Source
|
import eu.kanade.domain.source.model.Source
|
||||||
import eu.kanade.presentation.browse.SourceScreen
|
import eu.kanade.presentation.browse.SourcesScreen
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.SearchableComposeController
|
import eu.kanade.tachiyomi.ui.base.controller.SearchableComposeController
|
||||||
@ -28,11 +28,7 @@ import exh.ui.smartsearch.SmartSearchController
|
|||||||
import kotlinx.parcelize.Parcelize
|
import kotlinx.parcelize.Parcelize
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
|
|
||||||
/**
|
class SourcesController(bundle: Bundle? = null) : SearchableComposeController<SourcesPresenter>(bundle) {
|
||||||
* This controller shows and manages the different catalogues enabled by the user.
|
|
||||||
* This controller should only handle UI actions, IO actions should be done by [SourcePresenter]
|
|
||||||
*/
|
|
||||||
class SourceController(bundle: Bundle? = null) : SearchableComposeController<SourcePresenter>(bundle) {
|
|
||||||
|
|
||||||
private val preferences: PreferencesHelper by injectLazy()
|
private val preferences: PreferencesHelper by injectLazy()
|
||||||
|
|
||||||
@ -57,12 +53,11 @@ class SourceController(bundle: Bundle? = null) : SearchableComposeController<Sou
|
|||||||
// SY <--
|
// SY <--
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun createPresenter(): SourcePresenter =
|
override fun createPresenter() = SourcesPresenter(/* SY --> */ controllerMode = mode /* SY <-- */)
|
||||||
SourcePresenter(/* SY --> */ controllerMode = mode /* SY <-- */)
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
override fun ComposeContent(nestedScrollInterop: NestedScrollConnection) {
|
override fun ComposeContent(nestedScrollInterop: NestedScrollConnection) {
|
||||||
SourceScreen(
|
SourcesScreen(
|
||||||
nestedScrollInterop = nestedScrollInterop,
|
nestedScrollInterop = nestedScrollInterop,
|
||||||
presenter = presenter,
|
presenter = presenter,
|
||||||
onClickItem = { source ->
|
onClickItem = { source ->
|
||||||
@ -97,6 +92,7 @@ class SourceController(bundle: Bundle? = null) : SearchableComposeController<Sou
|
|||||||
presenter.toggleExcludeFromDataSaver(source)
|
presenter.toggleExcludeFromDataSaver(source)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
LaunchedEffect(Unit) {
|
LaunchedEffect(Unit) {
|
||||||
(activity as? MainActivity)?.ready = true
|
(activity as? MainActivity)?.ready = true
|
||||||
}
|
}
|
@ -25,11 +25,7 @@ import uy.kohesive.injekt.Injekt
|
|||||||
import uy.kohesive.injekt.api.get
|
import uy.kohesive.injekt.api.get
|
||||||
import java.util.TreeMap
|
import java.util.TreeMap
|
||||||
|
|
||||||
/**
|
class SourcesPresenter(
|
||||||
* Presenter of [SourceController]
|
|
||||||
* Function calls should be done from here. UI calls should be done from the controller.
|
|
||||||
*/
|
|
||||||
class SourcePresenter(
|
|
||||||
private val getEnabledSources: GetEnabledSources = Injekt.get(),
|
private val getEnabledSources: GetEnabledSources = Injekt.get(),
|
||||||
private val toggleSource: ToggleSource = Injekt.get(),
|
private val toggleSource: ToggleSource = Injekt.get(),
|
||||||
private val toggleSourcePin: ToggleSourcePin = Injekt.get(),
|
private val toggleSourcePin: ToggleSourcePin = Injekt.get(),
|
||||||
@ -38,9 +34,9 @@ class SourcePresenter(
|
|||||||
private val getShowLatest: GetShowLatest = Injekt.get(),
|
private val getShowLatest: GetShowLatest = Injekt.get(),
|
||||||
private val toggleExcludeFromDataSaver: ToggleExcludeFromDataSaver = Injekt.get(),
|
private val toggleExcludeFromDataSaver: ToggleExcludeFromDataSaver = Injekt.get(),
|
||||||
private val setSourceCategories: SetSourceCategories = Injekt.get(),
|
private val setSourceCategories: SetSourceCategories = Injekt.get(),
|
||||||
private val controllerMode: SourceController.Mode,
|
private val controllerMode: SourcesController.Mode,
|
||||||
// SY <--
|
// SY <--
|
||||||
) : BasePresenter<SourceController>() {
|
) : BasePresenter<SourcesController>() {
|
||||||
|
|
||||||
private val _state: MutableStateFlow<SourceState> = MutableStateFlow(SourceState.Loading)
|
private val _state: MutableStateFlow<SourceState> = MutableStateFlow(SourceState.Loading)
|
||||||
val state: StateFlow<SourceState> = _state.asStateFlow()
|
val state: StateFlow<SourceState> = _state.asStateFlow()
|
||||||
@ -52,7 +48,7 @@ class SourcePresenter(
|
|||||||
getEnabledSources.subscribe(),
|
getEnabledSources.subscribe(),
|
||||||
getSourceCategories.subscribe(),
|
getSourceCategories.subscribe(),
|
||||||
getShowLatest.subscribe(controllerMode),
|
getShowLatest.subscribe(controllerMode),
|
||||||
flowOf(controllerMode == SourceController.Mode.CATALOGUE),
|
flowOf(controllerMode == SourcesController.Mode.CATALOGUE),
|
||||||
::collectLatestSources,
|
::collectLatestSources,
|
||||||
)
|
)
|
||||||
.catch { exception ->
|
.catch { exception ->
|
||||||
@ -63,9 +59,9 @@ class SourcePresenter(
|
|||||||
// SY <--
|
// SY <--
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun collectLatestSources(sources: List<Source>, categories: Set<String>, showLatest: Boolean, showPin: Boolean) {
|
private fun collectLatestSources(sources: List<Source>, categories: Set<String>, showLatest: Boolean, showPin: Boolean) {
|
||||||
val map = TreeMap<String, MutableList<Source>> { d1, d2 ->
|
val map = TreeMap<String, MutableList<Source>> { d1, d2 ->
|
||||||
// Catalogues without a lang defined will be placed at the end
|
// Sources without a lang defined will be placed at the end
|
||||||
when {
|
when {
|
||||||
d1 == LAST_USED_KEY && d2 != LAST_USED_KEY -> -1
|
d1 == LAST_USED_KEY && d2 != LAST_USED_KEY -> -1
|
||||||
d2 == LAST_USED_KEY && d1 != LAST_USED_KEY -> 1
|
d2 == LAST_USED_KEY && d1 != LAST_USED_KEY -> 1
|
@ -37,7 +37,7 @@ import eu.kanade.tachiyomi.ui.base.controller.FabController
|
|||||||
import eu.kanade.tachiyomi.ui.base.controller.SearchableNucleusController
|
import eu.kanade.tachiyomi.ui.base.controller.SearchableNucleusController
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.pushController
|
import eu.kanade.tachiyomi.ui.base.controller.pushController
|
||||||
import eu.kanade.tachiyomi.ui.browse.extension.details.SourcePreferencesController
|
import eu.kanade.tachiyomi.ui.browse.extension.details.SourcePreferencesController
|
||||||
import eu.kanade.tachiyomi.ui.browse.source.SourceController
|
import eu.kanade.tachiyomi.ui.browse.source.SourcesController
|
||||||
import eu.kanade.tachiyomi.ui.browse.source.globalsearch.GlobalSearchController
|
import eu.kanade.tachiyomi.ui.browse.source.globalsearch.GlobalSearchController
|
||||||
import eu.kanade.tachiyomi.ui.library.ChangeMangaCategoriesDialog
|
import eu.kanade.tachiyomi.ui.library.ChangeMangaCategoriesDialog
|
||||||
import eu.kanade.tachiyomi.ui.library.setting.DisplayModeSetting
|
import eu.kanade.tachiyomi.ui.library.setting.DisplayModeSetting
|
||||||
@ -70,9 +70,6 @@ import kotlinx.coroutines.flow.launchIn
|
|||||||
import kotlinx.coroutines.flow.onEach
|
import kotlinx.coroutines.flow.onEach
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
|
|
||||||
/**
|
|
||||||
* Controller to manage the catalogues available in the app.
|
|
||||||
*/
|
|
||||||
open class BrowseSourceController(bundle: Bundle) :
|
open class BrowseSourceController(bundle: Bundle) :
|
||||||
SearchableNucleusController<SourceControllerBinding, BrowseSourcePresenter>(bundle),
|
SearchableNucleusController<SourceControllerBinding, BrowseSourcePresenter>(bundle),
|
||||||
FabController,
|
FabController,
|
||||||
@ -85,7 +82,7 @@ open class BrowseSourceController(bundle: Bundle) :
|
|||||||
sourceId: Long,
|
sourceId: Long,
|
||||||
query: String? = null,
|
query: String? = null,
|
||||||
// SY -->
|
// SY -->
|
||||||
smartSearchConfig: SourceController.SmartSearchConfig? = null,
|
smartSearchConfig: SourcesController.SmartSearchConfig? = null,
|
||||||
savedSearch: Long? = null,
|
savedSearch: Long? = null,
|
||||||
filterList: String? = null,
|
filterList: String? = null,
|
||||||
// SY <--
|
// SY <--
|
||||||
@ -116,7 +113,7 @@ open class BrowseSourceController(bundle: Bundle) :
|
|||||||
source: CatalogueSource,
|
source: CatalogueSource,
|
||||||
query: String? = null,
|
query: String? = null,
|
||||||
// SY -->
|
// SY -->
|
||||||
smartSearchConfig: SourceController.SmartSearchConfig? = null,
|
smartSearchConfig: SourcesController.SmartSearchConfig? = null,
|
||||||
savedSearch: Long? = null,
|
savedSearch: Long? = null,
|
||||||
filterList: String? = null,
|
filterList: String? = null,
|
||||||
// SY <--
|
// SY <--
|
||||||
@ -132,7 +129,7 @@ open class BrowseSourceController(bundle: Bundle) :
|
|||||||
source: Source,
|
source: Source,
|
||||||
query: String? = null,
|
query: String? = null,
|
||||||
// SY -->
|
// SY -->
|
||||||
smartSearchConfig: SourceController.SmartSearchConfig? = null,
|
smartSearchConfig: SourcesController.SmartSearchConfig? = null,
|
||||||
savedSearch: Long? = null,
|
savedSearch: Long? = null,
|
||||||
filterList: String? = null,
|
filterList: String? = null,
|
||||||
// SY <--
|
// SY <--
|
||||||
|
@ -71,9 +71,6 @@ import xyz.nulldev.ts.api.http.serializer.FilterSerializer
|
|||||||
import java.lang.RuntimeException
|
import java.lang.RuntimeException
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
|
|
||||||
/**
|
|
||||||
* Presenter of [BrowseSourceController].
|
|
||||||
*/
|
|
||||||
open class BrowseSourcePresenter(
|
open class BrowseSourcePresenter(
|
||||||
private val sourceId: Long,
|
private val sourceId: Long,
|
||||||
searchQuery: String? = null,
|
searchQuery: String? = null,
|
||||||
|
@ -5,7 +5,7 @@ import eu.kanade.tachiyomi.source.model.FilterList
|
|||||||
import eu.kanade.tachiyomi.source.model.MetadataMangasPage
|
import eu.kanade.tachiyomi.source.model.MetadataMangasPage
|
||||||
import eu.kanade.tachiyomi.util.lang.awaitSingle
|
import eu.kanade.tachiyomi.util.lang.awaitSingle
|
||||||
|
|
||||||
open class EHentaiPager(source: CatalogueSource, query: String, filters: FilterList) : SourcePager(source, query, filters) {
|
class EHentaiPager(val source: CatalogueSource, val query: String, val filters: FilterList) : Pager() {
|
||||||
|
|
||||||
private var lastMangaLink: String? = null
|
private var lastMangaLink: String? = null
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ import eu.kanade.tachiyomi.source.CatalogueSource
|
|||||||
import eu.kanade.tachiyomi.source.model.FilterList
|
import eu.kanade.tachiyomi.source.model.FilterList
|
||||||
import eu.kanade.tachiyomi.util.lang.awaitSingle
|
import eu.kanade.tachiyomi.util.lang.awaitSingle
|
||||||
|
|
||||||
open class SourcePager(val source: CatalogueSource, val query: String, val filters: FilterList) : Pager() {
|
class SourcePager(val source: CatalogueSource, val query: String, val filters: FilterList) : Pager() {
|
||||||
|
|
||||||
override suspend fun requestNextPage() {
|
override suspend fun requestNextPage() {
|
||||||
val page = currentPage
|
val page = currentPage
|
||||||
|
@ -93,7 +93,7 @@ open class GlobalSearchPresenter(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a list of enabled sources ordered by language and name, with pinned catalogues
|
* Returns a list of enabled sources ordered by language and name, with pinned sources
|
||||||
* prioritized.
|
* prioritized.
|
||||||
*
|
*
|
||||||
* @return list containing enabled sources.
|
* @return list containing enabled sources.
|
||||||
|
@ -65,8 +65,8 @@ import eu.kanade.tachiyomi.ui.base.controller.popControllerWithTag
|
|||||||
import eu.kanade.tachiyomi.ui.base.controller.pushController
|
import eu.kanade.tachiyomi.ui.base.controller.pushController
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
|
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
|
||||||
import eu.kanade.tachiyomi.ui.browse.migration.advanced.design.PreMigrationController
|
import eu.kanade.tachiyomi.ui.browse.migration.advanced.design.PreMigrationController
|
||||||
import eu.kanade.tachiyomi.ui.browse.source.SourceController
|
import eu.kanade.tachiyomi.ui.browse.source.SourcesController
|
||||||
import eu.kanade.tachiyomi.ui.browse.source.SourceController.Companion.SMART_SEARCH_SOURCE_TAG
|
import eu.kanade.tachiyomi.ui.browse.source.SourcesController.Companion.SMART_SEARCH_SOURCE_TAG
|
||||||
import eu.kanade.tachiyomi.ui.browse.source.browse.BrowseSourceController
|
import eu.kanade.tachiyomi.ui.browse.source.browse.BrowseSourceController
|
||||||
import eu.kanade.tachiyomi.ui.browse.source.feed.SourceFeedController
|
import eu.kanade.tachiyomi.ui.browse.source.feed.SourceFeedController
|
||||||
import eu.kanade.tachiyomi.ui.browse.source.globalsearch.GlobalSearchController
|
import eu.kanade.tachiyomi.ui.browse.source.globalsearch.GlobalSearchController
|
||||||
@ -140,7 +140,7 @@ class MangaController :
|
|||||||
|
|
||||||
constructor(history: HistoryWithRelations) : this(history.mangaId)
|
constructor(history: HistoryWithRelations) : this(history.mangaId)
|
||||||
|
|
||||||
constructor(manga: Manga?, fromSource: Boolean = false, smartSearchConfig: SourceController.SmartSearchConfig? = null, update: Boolean = false) : super(
|
constructor(manga: Manga?, fromSource: Boolean = false, smartSearchConfig: SourcesController.SmartSearchConfig? = null, update: Boolean = false) : super(
|
||||||
bundleOf(
|
bundleOf(
|
||||||
MANGA_EXTRA to (manga?.id ?: 0),
|
MANGA_EXTRA to (manga?.id ?: 0),
|
||||||
FROM_SOURCE_EXTRA to fromSource,
|
FROM_SOURCE_EXTRA to fromSource,
|
||||||
@ -239,7 +239,7 @@ class MangaController :
|
|||||||
}
|
}
|
||||||
|
|
||||||
// EXH -->
|
// EXH -->
|
||||||
val smartSearchConfig: SourceController.SmartSearchConfig? = args.getParcelable(
|
val smartSearchConfig: SourcesController.SmartSearchConfig? = args.getParcelable(
|
||||||
SMART_SEARCH_CONFIG_EXTRA,
|
SMART_SEARCH_CONFIG_EXTRA,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -732,12 +732,12 @@ class MangaController :
|
|||||||
|
|
||||||
// EXH -->
|
// EXH -->
|
||||||
fun openSmartSearch() {
|
fun openSmartSearch() {
|
||||||
val smartSearchConfig = SourceController.SmartSearchConfig(presenter.manga.title, presenter.manga.id)
|
val smartSearchConfig = SourcesController.SmartSearchConfig(presenter.manga.title, presenter.manga.id)
|
||||||
|
|
||||||
router?.pushController(
|
router?.pushController(
|
||||||
SourceController(
|
SourcesController(
|
||||||
bundleOf(
|
bundleOf(
|
||||||
SourceController.SMART_SEARCH_CONFIG to smartSearchConfig,
|
SourcesController.SMART_SEARCH_CONFIG to smartSearchConfig,
|
||||||
),
|
),
|
||||||
).withFadeTransaction().tag(SMART_SEARCH_SOURCE_TAG),
|
).withFadeTransaction().tag(SMART_SEARCH_SOURCE_TAG),
|
||||||
)
|
)
|
||||||
|
@ -17,7 +17,7 @@ import kotlin.math.abs
|
|||||||
/**
|
/**
|
||||||
* Implementation of a [RecyclerView] used by the webtoon reader.
|
* Implementation of a [RecyclerView] used by the webtoon reader.
|
||||||
*/
|
*/
|
||||||
open class WebtoonRecyclerView @JvmOverloads constructor(
|
class WebtoonRecyclerView @JvmOverloads constructor(
|
||||||
context: Context,
|
context: Context,
|
||||||
attrs: AttributeSet? = null,
|
attrs: AttributeSet? = null,
|
||||||
defStyle: Int = 0,
|
defStyle: Int = 0,
|
||||||
|
@ -6,11 +6,7 @@ import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter
|
|||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
import uy.kohesive.injekt.api.get
|
import uy.kohesive.injekt.api.get
|
||||||
|
|
||||||
/**
|
class SettingsSearchPresenter : BasePresenter<SettingsSearchController>() {
|
||||||
* Presenter of [SettingsSearchController]
|
|
||||||
* Function calls should be done from here. UI calls should be done from the controller.
|
|
||||||
*/
|
|
||||||
open class SettingsSearchPresenter : BasePresenter<SettingsSearchController>() {
|
|
||||||
|
|
||||||
val preferences: PreferencesHelper = Injekt.get()
|
val preferences: PreferencesHelper = Injekt.get()
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ package eu.kanade.tachiyomi.util.system
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import androidx.core.os.LocaleListCompat
|
import androidx.core.os.LocaleListCompat
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.ui.browse.source.SourcePresenter
|
import eu.kanade.tachiyomi.ui.browse.source.SourcesPresenter
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -21,8 +21,8 @@ object LocaleHelper {
|
|||||||
}
|
}
|
||||||
// SY <--
|
// SY <--
|
||||||
return when (lang) {
|
return when (lang) {
|
||||||
SourcePresenter.LAST_USED_KEY -> context.getString(R.string.last_used_source)
|
SourcesPresenter.LAST_USED_KEY -> context.getString(R.string.last_used_source)
|
||||||
SourcePresenter.PINNED_KEY -> context.getString(R.string.pinned_sources)
|
SourcesPresenter.PINNED_KEY -> context.getString(R.string.pinned_sources)
|
||||||
"other" -> context.getString(R.string.other_source)
|
"other" -> context.getString(R.string.other_source)
|
||||||
"all" -> context.getString(R.string.all_lang)
|
"all" -> context.getString(R.string.all_lang)
|
||||||
else -> getDisplayName(lang)
|
else -> getDisplayName(lang)
|
||||||
|
@ -8,7 +8,7 @@ import eu.kanade.tachiyomi.R
|
|||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
import eu.kanade.tachiyomi.source.CatalogueSource
|
import eu.kanade.tachiyomi.source.CatalogueSource
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.pushController
|
import eu.kanade.tachiyomi.ui.base.controller.pushController
|
||||||
import eu.kanade.tachiyomi.ui.browse.source.SourceController
|
import eu.kanade.tachiyomi.ui.browse.source.SourcesController
|
||||||
import eu.kanade.tachiyomi.ui.browse.source.browse.BrowseSourceController
|
import eu.kanade.tachiyomi.ui.browse.source.browse.BrowseSourceController
|
||||||
import eu.kanade.tachiyomi.ui.browse.source.browse.SourceItem
|
import eu.kanade.tachiyomi.ui.browse.source.browse.SourceItem
|
||||||
|
|
||||||
@ -50,11 +50,11 @@ class RecommendsController(bundle: Bundle) : BrowseSourceController(bundle) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun openSmartSearch(title: String) {
|
private fun openSmartSearch(title: String) {
|
||||||
val smartSearchConfig = SourceController.SmartSearchConfig(title)
|
val smartSearchConfig = SourcesController.SmartSearchConfig(title)
|
||||||
router.pushController(
|
router.pushController(
|
||||||
SourceController(
|
SourcesController(
|
||||||
bundleOf(
|
bundleOf(
|
||||||
SourceController.SMART_SEARCH_CONFIG to smartSearchConfig,
|
SourcesController.SMART_SEARCH_CONFIG to smartSearchConfig,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
@ -9,7 +9,7 @@ import eu.kanade.tachiyomi.source.CatalogueSource
|
|||||||
import eu.kanade.tachiyomi.source.SourceManager
|
import eu.kanade.tachiyomi.source.SourceManager
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.NucleusController
|
import eu.kanade.tachiyomi.ui.base.controller.NucleusController
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
|
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
|
||||||
import eu.kanade.tachiyomi.ui.browse.source.SourceController
|
import eu.kanade.tachiyomi.ui.browse.source.SourcesController
|
||||||
import eu.kanade.tachiyomi.ui.browse.source.browse.BrowseSourceController
|
import eu.kanade.tachiyomi.ui.browse.source.browse.BrowseSourceController
|
||||||
import eu.kanade.tachiyomi.ui.manga.MangaController
|
import eu.kanade.tachiyomi.ui.manga.MangaController
|
||||||
import eu.kanade.tachiyomi.util.system.toast
|
import eu.kanade.tachiyomi.util.system.toast
|
||||||
@ -22,7 +22,7 @@ class SmartSearchController(bundle: Bundle? = null) : NucleusController<EhSmartS
|
|||||||
private val sourceManager: SourceManager by injectLazy()
|
private val sourceManager: SourceManager by injectLazy()
|
||||||
|
|
||||||
private val source = sourceManager.get(bundle?.getLong(ARG_SOURCE_ID, -1) ?: -1) as? CatalogueSource
|
private val source = sourceManager.get(bundle?.getLong(ARG_SOURCE_ID, -1) ?: -1) as? CatalogueSource
|
||||||
private val smartSearchConfig: SourceController.SmartSearchConfig? = bundle?.getParcelable(
|
private val smartSearchConfig: SourcesController.SmartSearchConfig? = bundle?.getParcelable(
|
||||||
ARG_SMART_SEARCH_CONFIG,
|
ARG_SMART_SEARCH_CONFIG,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ package exh.ui.smartsearch
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
import eu.kanade.tachiyomi.source.CatalogueSource
|
import eu.kanade.tachiyomi.source.CatalogueSource
|
||||||
import eu.kanade.tachiyomi.ui.browse.source.SourceController
|
import eu.kanade.tachiyomi.ui.browse.source.SourcesController
|
||||||
import eu.kanade.tachiyomi.util.lang.launchIO
|
import eu.kanade.tachiyomi.util.lang.launchIO
|
||||||
import exh.smartsearch.SmartSearchEngine
|
import exh.smartsearch.SmartSearchEngine
|
||||||
import exh.ui.base.CoroutinePresenter
|
import exh.ui.base.CoroutinePresenter
|
||||||
@ -11,7 +11,7 @@ import kotlinx.coroutines.CancellationException
|
|||||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
import kotlinx.coroutines.flow.MutableSharedFlow
|
||||||
import kotlinx.coroutines.flow.asSharedFlow
|
import kotlinx.coroutines.flow.asSharedFlow
|
||||||
|
|
||||||
class SmartSearchPresenter(private val source: CatalogueSource, private val config: SourceController.SmartSearchConfig) :
|
class SmartSearchPresenter(private val source: CatalogueSource, private val config: SourcesController.SmartSearchConfig) :
|
||||||
CoroutinePresenter<SmartSearchController>() {
|
CoroutinePresenter<SmartSearchController>() {
|
||||||
|
|
||||||
private val _smartSearchFlow = MutableSharedFlow<SearchResults>()
|
private val _smartSearchFlow = MutableSharedFlow<SearchResults>()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user