mirror of
https://github.com/aniyomiorg/aniyomi.git
synced 2024-11-28 09:15:12 +03:00
Minor cleanup
This commit is contained in:
parent
d61bfd7caf
commit
9f42306f79
18 changed files with 40 additions and 70 deletions
|
@ -1,4 +1,4 @@
|
|||
package eu.kanade.presentation.extension
|
||||
package eu.kanade.presentation.browse
|
||||
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.compose.foundation.combinedClickable
|
||||
|
@ -47,15 +47,15 @@ import eu.kanade.presentation.util.topPaddingValues
|
|||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.extension.model.Extension
|
||||
import eu.kanade.tachiyomi.extension.model.InstallStep
|
||||
import eu.kanade.tachiyomi.ui.browse.extension.ExtensionPresenter
|
||||
import eu.kanade.tachiyomi.ui.browse.extension.ExtensionState
|
||||
import eu.kanade.tachiyomi.ui.browse.extension.ExtensionUiModel
|
||||
import eu.kanade.tachiyomi.ui.browse.extension.ExtensionsPresenter
|
||||
import eu.kanade.tachiyomi.util.system.LocaleHelper
|
||||
|
||||
@Composable
|
||||
fun ExtensionScreen(
|
||||
nestedScrollInterop: NestedScrollConnection,
|
||||
presenter: ExtensionPresenter,
|
||||
presenter: ExtensionsPresenter,
|
||||
onLongClickItem: (Extension) -> Unit,
|
||||
onClickItemCancel: (Extension) -> Unit,
|
||||
onInstallExtension: (Extension.Available) -> Unit,
|
||||
|
@ -112,6 +112,7 @@ fun ExtensionContent(
|
|||
) {
|
||||
val (trustState, setTrustState) = remember { mutableStateOf<Extension.Untrusted?>(null) }
|
||||
LazyColumn(
|
||||
modifier = Modifier.nestedScroll(nestedScrollInterop),
|
||||
contentPadding = WindowInsets.navigationBars.asPaddingValues() + topPaddingValues,
|
||||
) {
|
||||
items(
|
|
@ -41,14 +41,14 @@ import eu.kanade.presentation.util.plus
|
|||
import eu.kanade.presentation.util.topPaddingValues
|
||||
import eu.kanade.tachiyomi.R
|
||||
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.SourcesPresenter
|
||||
import eu.kanade.tachiyomi.util.system.LocaleHelper
|
||||
|
||||
@Composable
|
||||
fun SourceScreen(
|
||||
fun SourcesScreen(
|
||||
nestedScrollInterop: NestedScrollConnection,
|
||||
presenter: SourcePresenter,
|
||||
presenter: SourcesPresenter,
|
||||
onClickItem: (Source) -> Unit,
|
||||
onClickDisable: (Source) -> Unit,
|
||||
onClickLatest: (Source) -> Unit,
|
||||
|
@ -86,8 +86,7 @@ fun SourceList(
|
|||
|
||||
val (sourceState, setSourceState) = remember { mutableStateOf<Source?>(null) }
|
||||
LazyColumn(
|
||||
modifier = Modifier
|
||||
.nestedScroll(nestedScrollConnection),
|
||||
modifier = Modifier.nestedScroll(nestedScrollConnection),
|
||||
contentPadding = WindowInsets.navigationBars.asPaddingValues() + topPaddingValues,
|
||||
) {
|
||||
items(
|
|
@ -54,7 +54,7 @@ import uy.kohesive.injekt.api.get
|
|||
import uy.kohesive.injekt.injectLazy
|
||||
import java.security.Security
|
||||
|
||||
open class App : Application(), DefaultLifecycleObserver, ImageLoaderFactory {
|
||||
class App : Application(), DefaultLifecycleObserver, ImageLoaderFactory {
|
||||
|
||||
private val preferences: PreferencesHelper by injectLazy()
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ class AppModule(val app: Application) : InjektModule {
|
|||
|
||||
addSingletonFactory { PreferencesHelper(app) }
|
||||
|
||||
addSingletonFactory { DatabaseHelper(app, get()) }
|
||||
addSingletonFactory { DatabaseHelper(get()) }
|
||||
|
||||
addSingletonFactory { ChapterCache(app) }
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package eu.kanade.tachiyomi.data.database
|
||||
|
||||
import android.content.Context
|
||||
import androidx.sqlite.db.SupportSQLiteOpenHelper
|
||||
import com.pushtorefresh.storio.sqlite.impl.DefaultStorIOSQLite
|
||||
import eu.kanade.tachiyomi.data.database.mappers.CategoryTypeMapping
|
||||
|
@ -25,8 +24,7 @@ import eu.kanade.tachiyomi.data.database.queries.TrackQueries
|
|||
/**
|
||||
* This class provides operations to manage the database through its interfaces.
|
||||
*/
|
||||
open class DatabaseHelper(
|
||||
context: Context,
|
||||
class DatabaseHelper(
|
||||
openHelper: SupportSQLiteOpenHelper,
|
||||
) :
|
||||
MangaQueries, ChapterQueries, TrackQueries, CategoryQueries, MangaCategoryQueries, HistoryQueries {
|
||||
|
|
|
@ -14,7 +14,7 @@ import rx.Observable
|
|||
import tachiyomi.source.model.ChapterInfo
|
||||
import tachiyomi.source.model.MangaInfo
|
||||
|
||||
open class SourceManager(private val context: Context) {
|
||||
class SourceManager(private val context: Context) {
|
||||
|
||||
private val sourcesMap = mutableMapOf<Long, Source>()
|
||||
private val stubSourcesMap = mutableMapOf<Long, StubSource>()
|
||||
|
@ -28,7 +28,7 @@ open class SourceManager(private val context: Context) {
|
|||
createInternalSources().forEach { registerSource(it) }
|
||||
}
|
||||
|
||||
open fun get(sourceKey: Long): Source? {
|
||||
fun get(sourceKey: Long): Source? {
|
||||
return sourcesMap[sourceKey]
|
||||
}
|
||||
|
||||
|
|
|
@ -19,9 +19,9 @@ import eu.kanade.tachiyomi.databinding.PagerControllerBinding
|
|||
import eu.kanade.tachiyomi.ui.base.controller.RootController
|
||||
import eu.kanade.tachiyomi.ui.base.controller.RxController
|
||||
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.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 uy.kohesive.injekt.injectLazy
|
||||
|
||||
|
@ -125,8 +125,8 @@ class BrowseController :
|
|||
override fun configureRouter(router: Router, position: Int) {
|
||||
if (!router.hasRootController()) {
|
||||
val controller: Controller = when (position) {
|
||||
SOURCES_CONTROLLER -> SourceController()
|
||||
EXTENSIONS_CONTROLLER -> ExtensionController()
|
||||
SOURCES_CONTROLLER -> SourcesController()
|
||||
EXTENSIONS_CONTROLLER -> ExtensionsController()
|
||||
MIGRATION_CONTROLLER -> MigrationSourcesController()
|
||||
else -> error("Wrong position $position")
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import androidx.compose.runtime.Composable
|
|||
import androidx.compose.ui.input.nestedscroll.NestedScrollConnection
|
||||
import com.bluelinelabs.conductor.ControllerChangeHandler
|
||||
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.extension.model.Extension
|
||||
import eu.kanade.tachiyomi.ui.base.controller.ComposeController
|
||||
|
@ -20,11 +20,7 @@ import kotlinx.coroutines.flow.launchIn
|
|||
import kotlinx.coroutines.flow.onEach
|
||||
import reactivecircus.flowbinding.appcompat.queryTextChanges
|
||||
|
||||
/**
|
||||
* Controller to manage the catalogues available in the app.
|
||||
*/
|
||||
open class ExtensionController :
|
||||
ComposeController<ExtensionPresenter>() {
|
||||
class ExtensionsController : ComposeController<ExtensionsPresenter>() {
|
||||
|
||||
private var query = ""
|
||||
|
||||
|
@ -32,11 +28,9 @@ open class ExtensionController :
|
|||
setHasOptionsMenu(true)
|
||||
}
|
||||
|
||||
override fun getTitle(): String? =
|
||||
applicationContext?.getString(R.string.label_extensions)
|
||||
override fun getTitle() = applicationContext?.getString(R.string.label_extensions)
|
||||
|
||||
override fun createPresenter(): ExtensionPresenter =
|
||||
ExtensionPresenter()
|
||||
override fun createPresenter() = ExtensionsPresenter()
|
||||
|
||||
@Composable
|
||||
override fun ComposeContent(nestedScrollInterop: NestedScrollConnection) {
|
|
@ -26,14 +26,11 @@ import rx.Observable
|
|||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
||||
/**
|
||||
* Presenter of [ExtensionController].
|
||||
*/
|
||||
open class ExtensionPresenter(
|
||||
class ExtensionsPresenter(
|
||||
private val extensionManager: ExtensionManager = Injekt.get(),
|
||||
private val getExtensionUpdates: GetExtensionUpdates = Injekt.get(),
|
||||
private val getExtensions: GetExtensions = Injekt.get(),
|
||||
) : BasePresenter<ExtensionController>() {
|
||||
) : BasePresenter<ExtensionsController>() {
|
||||
|
||||
private val _query: MutableStateFlow<String> = MutableStateFlow("")
|
||||
|
|
@ -9,7 +9,7 @@ import androidx.compose.runtime.Composable
|
|||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.ui.input.nestedscroll.NestedScrollConnection
|
||||
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.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.ui.base.controller.SearchableComposeController
|
||||
|
@ -21,11 +21,7 @@ import eu.kanade.tachiyomi.ui.browse.source.latest.LatestUpdatesController
|
|||
import eu.kanade.tachiyomi.ui.main.MainActivity
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
||||
/**
|
||||
* 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 : SearchableComposeController<SourcePresenter>() {
|
||||
class SourcesController : SearchableComposeController<SourcesPresenter>() {
|
||||
|
||||
private val preferences: PreferencesHelper by injectLazy()
|
||||
|
||||
|
@ -33,15 +29,13 @@ class SourceController : SearchableComposeController<SourcePresenter>() {
|
|||
setHasOptionsMenu(true)
|
||||
}
|
||||
|
||||
override fun getTitle(): String? =
|
||||
resources?.getString(R.string.label_sources)
|
||||
override fun getTitle() = resources?.getString(R.string.label_sources)
|
||||
|
||||
override fun createPresenter(): SourcePresenter =
|
||||
SourcePresenter()
|
||||
override fun createPresenter() = SourcesPresenter()
|
||||
|
||||
@Composable
|
||||
override fun ComposeContent(nestedScrollInterop: NestedScrollConnection) {
|
||||
SourceScreen(
|
||||
SourcesScreen(
|
||||
nestedScrollInterop = nestedScrollInterop,
|
||||
presenter = presenter,
|
||||
onClickItem = { source ->
|
||||
|
@ -57,6 +51,7 @@ class SourceController : SearchableComposeController<SourcePresenter>() {
|
|||
presenter.togglePin(source)
|
||||
},
|
||||
)
|
||||
|
||||
LaunchedEffect(Unit) {
|
||||
(activity as? MainActivity)?.ready = true
|
||||
}
|
|
@ -18,15 +18,11 @@ import uy.kohesive.injekt.Injekt
|
|||
import uy.kohesive.injekt.api.get
|
||||
import java.util.TreeMap
|
||||
|
||||
/**
|
||||
* Presenter of [SourceController]
|
||||
* Function calls should be done from here. UI calls should be done from the controller.
|
||||
*/
|
||||
class SourcePresenter(
|
||||
class SourcesPresenter(
|
||||
private val getEnabledSources: GetEnabledSources = Injekt.get(),
|
||||
private val toggleSource: ToggleSource = Injekt.get(),
|
||||
private val toggleSourcePin: ToggleSourcePin = Injekt.get(),
|
||||
) : BasePresenter<SourceController>() {
|
||||
) : BasePresenter<SourcesController>() {
|
||||
|
||||
private val _state: MutableStateFlow<SourceState> = MutableStateFlow(SourceState.Loading)
|
||||
val state: StateFlow<SourceState> = _state.asStateFlow()
|
||||
|
@ -42,9 +38,9 @@ class SourcePresenter(
|
|||
}
|
||||
}
|
||||
|
||||
private suspend fun collectLatestSources(sources: List<Source>) {
|
||||
private fun collectLatestSources(sources: List<Source>) {
|
||||
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 {
|
||||
d1 == LAST_USED_KEY && d2 != LAST_USED_KEY -> -1
|
||||
d2 == LAST_USED_KEY && d1 != LAST_USED_KEY -> 1
|
|
@ -60,9 +60,6 @@ import kotlinx.coroutines.flow.onEach
|
|||
import logcat.LogPriority
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
||||
/**
|
||||
* Controller to manage the catalogues available in the app.
|
||||
*/
|
||||
open class BrowseSourceController(bundle: Bundle) :
|
||||
SearchableNucleusController<SourceControllerBinding, BrowseSourcePresenter>(bundle),
|
||||
FabController,
|
||||
|
|
|
@ -53,9 +53,6 @@ import uy.kohesive.injekt.Injekt
|
|||
import uy.kohesive.injekt.api.get
|
||||
import java.util.Date
|
||||
|
||||
/**
|
||||
* Presenter of [BrowseSourceController].
|
||||
*/
|
||||
open class BrowseSourcePresenter(
|
||||
private val sourceId: Long,
|
||||
searchQuery: String? = null,
|
||||
|
|
|
@ -4,7 +4,7 @@ import eu.kanade.tachiyomi.source.CatalogueSource
|
|||
import eu.kanade.tachiyomi.source.model.FilterList
|
||||
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() {
|
||||
val page = currentPage
|
||||
|
|
|
@ -92,7 +92,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.
|
||||
*
|
||||
* @return list containing enabled sources.
|
||||
|
|
|
@ -17,7 +17,7 @@ import kotlin.math.abs
|
|||
/**
|
||||
* Implementation of a [RecyclerView] used by the webtoon reader.
|
||||
*/
|
||||
open class WebtoonRecyclerView @JvmOverloads constructor(
|
||||
class WebtoonRecyclerView @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyle: Int = 0,
|
||||
|
|
|
@ -6,11 +6,7 @@ import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter
|
|||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
||||
/**
|
||||
* Presenter of [SettingsSearchController]
|
||||
* Function calls should be done from here. UI calls should be done from the controller.
|
||||
*/
|
||||
open class SettingsSearchPresenter : BasePresenter<SettingsSearchController>() {
|
||||
class SettingsSearchPresenter : BasePresenter<SettingsSearchController>() {
|
||||
|
||||
val preferences: PreferencesHelper = Injekt.get()
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ package eu.kanade.tachiyomi.util.system
|
|||
import android.content.Context
|
||||
import androidx.core.os.LocaleListCompat
|
||||
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
|
||||
|
||||
/**
|
||||
|
@ -16,8 +16,8 @@ object LocaleHelper {
|
|||
*/
|
||||
fun getSourceDisplayName(lang: String?, context: Context): String {
|
||||
return when (lang) {
|
||||
SourcePresenter.LAST_USED_KEY -> context.getString(R.string.last_used_source)
|
||||
SourcePresenter.PINNED_KEY -> context.getString(R.string.pinned_sources)
|
||||
SourcesPresenter.LAST_USED_KEY -> context.getString(R.string.last_used_source)
|
||||
SourcesPresenter.PINNED_KEY -> context.getString(R.string.pinned_sources)
|
||||
"other" -> context.getString(R.string.other_source)
|
||||
"all" -> context.getString(R.string.all_lang)
|
||||
else -> getDisplayName(lang)
|
||||
|
|
Loading…
Reference in a new issue