diff --git a/app/src/main/java/eu/kanade/presentation/extension/ExtensionScreen.kt b/app/src/main/java/eu/kanade/presentation/browse/ExtensionsScreen.kt similarity index 98% rename from app/src/main/java/eu/kanade/presentation/extension/ExtensionScreen.kt rename to app/src/main/java/eu/kanade/presentation/browse/ExtensionsScreen.kt index 72fa76c0b..f064a4a1c 100644 --- a/app/src/main/java/eu/kanade/presentation/extension/ExtensionScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/browse/ExtensionsScreen.kt @@ -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(null) } LazyColumn( + modifier = Modifier.nestedScroll(nestedScrollInterop), contentPadding = WindowInsets.navigationBars.asPaddingValues() + topPaddingValues, ) { items( diff --git a/app/src/main/java/eu/kanade/presentation/browse/SourceScreen.kt b/app/src/main/java/eu/kanade/presentation/browse/SourcesScreen.kt similarity index 97% rename from app/src/main/java/eu/kanade/presentation/browse/SourceScreen.kt rename to app/src/main/java/eu/kanade/presentation/browse/SourcesScreen.kt index bfac929bb..b581a772e 100644 --- a/app/src/main/java/eu/kanade/presentation/browse/SourceScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/browse/SourcesScreen.kt @@ -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(null) } LazyColumn( - modifier = Modifier - .nestedScroll(nestedScrollConnection), + modifier = Modifier.nestedScroll(nestedScrollConnection), contentPadding = WindowInsets.navigationBars.asPaddingValues() + topPaddingValues, ) { items( diff --git a/app/src/main/java/eu/kanade/tachiyomi/App.kt b/app/src/main/java/eu/kanade/tachiyomi/App.kt index acb62da13..18fe23057 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/App.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/App.kt @@ -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() diff --git a/app/src/main/java/eu/kanade/tachiyomi/AppModule.kt b/app/src/main/java/eu/kanade/tachiyomi/AppModule.kt index e199f01b5..0d365840c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/AppModule.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/AppModule.kt @@ -70,7 +70,7 @@ class AppModule(val app: Application) : InjektModule { addSingletonFactory { PreferencesHelper(app) } - addSingletonFactory { DatabaseHelper(app, get()) } + addSingletonFactory { DatabaseHelper(get()) } addSingletonFactory { ChapterCache(app) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/DatabaseHelper.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/DatabaseHelper.kt index 1fbf55ad6..ff38f1bcd 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/DatabaseHelper.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/DatabaseHelper.kt @@ -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 { diff --git a/app/src/main/java/eu/kanade/tachiyomi/source/SourceManager.kt b/app/src/main/java/eu/kanade/tachiyomi/source/SourceManager.kt index 4e3495a2f..87e1a7100 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/source/SourceManager.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/source/SourceManager.kt @@ -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() private val stubSourcesMap = mutableMapOf() @@ -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] } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/BrowseController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/BrowseController.kt index bd8173d34..fda117aa8 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/BrowseController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/BrowseController.kt @@ -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") } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionsController.kt similarity index 91% rename from app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionController.kt rename to app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionsController.kt index 8112692b7..abb33f7ad 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionsController.kt @@ -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() { +class ExtensionsController : ComposeController() { 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) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionsPresenter.kt similarity index 98% rename from app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionPresenter.kt rename to app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionsPresenter.kt index 76b38aa06..48cbe3e5f 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionsPresenter.kt @@ -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() { +) : BasePresenter() { private val _query: MutableStateFlow = MutableStateFlow("") diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourceController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourcesController.kt similarity index 87% rename from app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourceController.kt rename to app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourcesController.kt index 45d491bda..9de8945a3 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourceController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourcesController.kt @@ -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() { +class SourcesController : SearchableComposeController() { private val preferences: PreferencesHelper by injectLazy() @@ -33,15 +29,13 @@ class SourceController : SearchableComposeController() { 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() { presenter.togglePin(source) }, ) + LaunchedEffect(Unit) { (activity as? MainActivity)?.ready = true } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourcePresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourcesPresenter.kt similarity index 89% rename from app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourcePresenter.kt rename to app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourcesPresenter.kt index 365304da5..b1e6cb38b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourcePresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourcesPresenter.kt @@ -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() { +) : BasePresenter() { private val _state: MutableStateFlow = MutableStateFlow(SourceState.Loading) val state: StateFlow = _state.asStateFlow() @@ -42,9 +38,9 @@ class SourcePresenter( } } - private suspend fun collectLatestSources(sources: List) { + private fun collectLatestSources(sources: List) { val map = TreeMap> { 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 diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceController.kt index cac78a0a4..89a88d733 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceController.kt @@ -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(bundle), FabController, diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourcePresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourcePresenter.kt index afcb0c60e..6b0694c93 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourcePresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourcePresenter.kt @@ -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, diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/SourcePager.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/SourcePager.kt index 3d7970172..786ffca3a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/SourcePager.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/SourcePager.kt @@ -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 diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchPresenter.kt index ddf43b40b..0b1d04829 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchPresenter.kt @@ -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. diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonRecyclerView.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonRecyclerView.kt index 62670320d..e04fecfc0 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonRecyclerView.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonRecyclerView.kt @@ -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, diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/search/SettingsSearchPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/search/SettingsSearchPresenter.kt index 0d03d7561..6587d100a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/search/SettingsSearchPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/search/SettingsSearchPresenter.kt @@ -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() { +class SettingsSearchPresenter : BasePresenter() { val preferences: PreferencesHelper = Injekt.get() diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/system/LocaleHelper.kt b/app/src/main/java/eu/kanade/tachiyomi/util/system/LocaleHelper.kt index ab70be2ee..d193de5e5 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/system/LocaleHelper.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/system/LocaleHelper.kt @@ -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)