Rename SourceController and title to Browse

This commit is contained in:
Jays2Kings 2021-03-29 14:47:42 -04:00
parent 632d2759cb
commit 2e563d7d0c
9 changed files with 26 additions and 27 deletions

View File

@ -11,7 +11,7 @@ import eu.kanade.tachiyomi.R
class CenteredToolbar@JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : class CenteredToolbar@JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
MaterialToolbar(context, attrs) { MaterialToolbar(context, attrs) {
private lateinit var toolbarTitle:TextView private lateinit var toolbarTitle: TextView
override fun onFinishInflate() { override fun onFinishInflate() {
super.onFinishInflate() super.onFinishInflate()
toolbarTitle = findViewById<MaterialTextView>(R.id.toolbar_title) toolbarTitle = findViewById<MaterialTextView>(R.id.toolbar_title)

View File

@ -21,7 +21,7 @@ import eu.kanade.tachiyomi.ui.migration.MangaItem
import eu.kanade.tachiyomi.ui.migration.SourceAdapter import eu.kanade.tachiyomi.ui.migration.SourceAdapter
import eu.kanade.tachiyomi.ui.migration.SourceItem import eu.kanade.tachiyomi.ui.migration.SourceItem
import eu.kanade.tachiyomi.ui.migration.manga.design.PreMigrationController import eu.kanade.tachiyomi.ui.migration.manga.design.PreMigrationController
import eu.kanade.tachiyomi.ui.source.SourceController import eu.kanade.tachiyomi.ui.source.BrowseController
import eu.kanade.tachiyomi.util.view.collapse import eu.kanade.tachiyomi.util.view.collapse
import eu.kanade.tachiyomi.util.view.doOnApplyWindowInsets import eu.kanade.tachiyomi.util.view.doOnApplyWindowInsets
import eu.kanade.tachiyomi.util.view.expand import eu.kanade.tachiyomi.util.view.expand
@ -60,14 +60,14 @@ class ExtensionBottomSheet @JvmOverloads constructor(context: Context, attrs: At
private var extensions: List<ExtensionItem> = emptyList() private var extensions: List<ExtensionItem> = emptyList()
var canExpand = false var canExpand = false
lateinit var controller: SourceController lateinit var controller: BrowseController
val extensionFrameLayout = val extensionFrameLayout =
inflate(context, R.layout.recycler_with_scroller, null) as FrameLayout inflate(context, R.layout.recycler_with_scroller, null) as FrameLayout
val migrationFrameLayout = val migrationFrameLayout =
inflate(context, R.layout.recycler_with_scroller, null) as FrameLayout inflate(context, R.layout.recycler_with_scroller, null) as FrameLayout
fun onCreate(controller: SourceController) { fun onCreate(controller: BrowseController) {
// Initialize adapter, scroll listener and recycler views // Initialize adapter, scroll listener and recycler views
adapter = ExtensionAdapter(this) adapter = ExtensionAdapter(this)
migAdapter = ExtensionAdapter(this) migAdapter = ExtensionAdapter(this)

View File

@ -59,7 +59,7 @@ import eu.kanade.tachiyomi.ui.security.SecureActivityDelegate
import eu.kanade.tachiyomi.ui.setting.AboutController import eu.kanade.tachiyomi.ui.setting.AboutController
import eu.kanade.tachiyomi.ui.setting.SettingsController import eu.kanade.tachiyomi.ui.setting.SettingsController
import eu.kanade.tachiyomi.ui.setting.SettingsMainController import eu.kanade.tachiyomi.ui.setting.SettingsMainController
import eu.kanade.tachiyomi.ui.source.SourceController import eu.kanade.tachiyomi.ui.source.BrowseController
import eu.kanade.tachiyomi.util.system.contextCompatDrawable import eu.kanade.tachiyomi.util.system.contextCompatDrawable
import eu.kanade.tachiyomi.util.system.getResourceColor import eu.kanade.tachiyomi.util.system.getResourceColor
import eu.kanade.tachiyomi.util.system.hasSideNavBar import eu.kanade.tachiyomi.util.system.hasSideNavBar
@ -194,7 +194,7 @@ open class MainActivity : BaseActivity<MainActivityBinding>(), DownloadServiceLi
when (id) { when (id) {
R.id.nav_library -> LibraryController() R.id.nav_library -> LibraryController()
R.id.nav_recents -> RecentsController() R.id.nav_recents -> RecentsController()
else -> SourceController() else -> BrowseController()
}, },
id id
) )
@ -485,7 +485,7 @@ open class MainActivity : BaseActivity<MainActivityBinding>(), DownloadServiceLi
router.popToRoot() router.popToRoot()
binding.bottomNav.post { binding.bottomNav.post {
val controller = val controller =
router.backstack.firstOrNull()?.controller() as? SourceController router.backstack.firstOrNull()?.controller() as? BrowseController
controller?.showSheet() controller?.showSheet()
} }
} }

View File

@ -81,7 +81,7 @@ import eu.kanade.tachiyomi.ui.manga.track.TrackingBottomSheet
import eu.kanade.tachiyomi.ui.migration.manga.design.PreMigrationController import eu.kanade.tachiyomi.ui.migration.manga.design.PreMigrationController
import eu.kanade.tachiyomi.ui.reader.ReaderActivity import eu.kanade.tachiyomi.ui.reader.ReaderActivity
import eu.kanade.tachiyomi.ui.security.SecureActivityDelegate import eu.kanade.tachiyomi.ui.security.SecureActivityDelegate
import eu.kanade.tachiyomi.ui.source.SourceController import eu.kanade.tachiyomi.ui.source.BrowseController
import eu.kanade.tachiyomi.ui.source.global_search.GlobalSearchController import eu.kanade.tachiyomi.ui.source.global_search.GlobalSearchController
import eu.kanade.tachiyomi.ui.webview.WebViewActivity import eu.kanade.tachiyomi.ui.webview.WebViewActivity
import eu.kanade.tachiyomi.util.storage.getUriCompat import eu.kanade.tachiyomi.util.storage.getUriCompat
@ -123,7 +123,7 @@ class MangaDetailsController :
constructor( constructor(
manga: Manga?, manga: Manga?,
fromCatalogue: Boolean = false, fromCatalogue: Boolean = false,
smartSearchConfig: SourceController.SmartSearchConfig? = null, smartSearchConfig: BrowseController.SmartSearchConfig? = null,
update: Boolean = false update: Boolean = false
) : super( ) : super(
Bundle().apply { Bundle().apply {

View File

@ -24,7 +24,7 @@ import eu.davidea.flexibleadapter.items.IFlexible
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.data.preference.getOrDefault import eu.kanade.tachiyomi.data.preference.getOrDefault
import eu.kanade.tachiyomi.databinding.SourceControllerBinding import eu.kanade.tachiyomi.databinding.BrowseControllerBinding
import eu.kanade.tachiyomi.source.CatalogueSource import eu.kanade.tachiyomi.source.CatalogueSource
import eu.kanade.tachiyomi.source.Source import eu.kanade.tachiyomi.source.Source
import eu.kanade.tachiyomi.ui.base.controller.NucleusController import eu.kanade.tachiyomi.ui.base.controller.NucleusController
@ -59,12 +59,10 @@ import kotlinx.android.synthetic.main.extensions_bottom_sheet.ext_bottom_sheet
import kotlinx.android.synthetic.main.extensions_bottom_sheet.sheet_layout import kotlinx.android.synthetic.main.extensions_bottom_sheet.sheet_layout
import kotlinx.android.synthetic.main.extensions_bottom_sheet.view.* import kotlinx.android.synthetic.main.extensions_bottom_sheet.view.*
import kotlinx.android.synthetic.main.filter_bottom_sheet.* import kotlinx.android.synthetic.main.filter_bottom_sheet.*
import kotlinx.android.synthetic.main.library_list_controller.*
import kotlinx.android.synthetic.main.main_activity.* import kotlinx.android.synthetic.main.main_activity.*
import kotlinx.android.synthetic.main.recycler_with_scroller.view.* import kotlinx.android.synthetic.main.recycler_with_scroller.view.*
import kotlinx.android.synthetic.main.rounded_category_hopper.* import kotlinx.android.synthetic.main.rounded_category_hopper.*
import kotlinx.android.synthetic.main.source_controller.* import kotlinx.android.synthetic.main.browse_controller.*
import kotlinx.android.synthetic.main.source_controller.shadow2
import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get import uy.kohesive.injekt.api.get
import kotlin.math.max import kotlin.math.max
@ -76,8 +74,8 @@ import kotlin.math.min
* [SourceAdapter.SourceListener] call function data on browse item click. * [SourceAdapter.SourceListener] call function data on browse item click.
* [SourceAdapter.OnLatestClickListener] call function data on latest item click * [SourceAdapter.OnLatestClickListener] call function data on latest item click
*/ */
class SourceController : class BrowseController :
NucleusController<SourceControllerBinding, SourcePresenter>(), NucleusController<BrowseControllerBinding, SourcePresenter>(),
FlexibleAdapter.OnItemClickListener, FlexibleAdapter.OnItemClickListener,
SourceAdapter.SourceListener, SourceAdapter.SourceListener,
RootSearchInterface, RootSearchInterface,
@ -117,7 +115,7 @@ class SourceController :
else -> R.string.source_migration else -> R.string.source_migration
} }
) )
} else view?.context?.getString(R.string.sources) } else view?.context?.getString(R.string.browse)
} }
override fun createPresenter(): SourcePresenter { override fun createPresenter(): SourcePresenter {
@ -125,14 +123,14 @@ class SourceController :
} }
/** /**
* Initiate the view with [R.layout.source_controller]. * Initiate the view with [R.layout.browse_controller].
* *
* @param inflater used to load the layout xml. * @param inflater used to load the layout xml.
* @param container containing parent views. * @param container containing parent views.
* @return inflated view. * @return inflated view.
*/ */
override fun inflateView(inflater: LayoutInflater, container: ViewGroup): View { override fun inflateView(inflater: LayoutInflater, container: ViewGroup): View {
return inflater.inflate(R.layout.source_controller, container, false) return inflater.inflate(R.layout.browse_controller, container, false)
} }
override fun onViewCreated(view: View) { override fun onViewCreated(view: View) {

View File

@ -6,9 +6,9 @@ import eu.davidea.flexibleadapter.items.IFlexible
/** /**
* Adapter that holds the catalogue cards. * Adapter that holds the catalogue cards.
* *
* @param controller instance of [SourceController]. * @param controller instance of [BrowseController].
*/ */
class SourceAdapter(val controller: SourceController) : class SourceAdapter(val controller: BrowseController) :
FlexibleAdapter<IFlexible<*>>(null, controller, true) { FlexibleAdapter<IFlexible<*>>(null, controller, true) {
init { init {

View File

@ -16,7 +16,7 @@ import java.util.TreeMap
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
/** /**
* Presenter of [SourceController] * Presenter of [BrowseController]
* Function calls should be done from here. UI calls should be done from the controller. * Function calls should be done from here. UI calls should be done from the controller.
* *
* @param sourceManager manages the different sources. * @param sourceManager manages the different sources.
@ -25,7 +25,7 @@ import java.util.concurrent.TimeUnit
class SourcePresenter( class SourcePresenter(
val sourceManager: SourceManager = Injekt.get(), val sourceManager: SourceManager = Injekt.get(),
private val preferences: PreferencesHelper = Injekt.get() private val preferences: PreferencesHelper = Injekt.get()
) : BasePresenter<SourceController>() { ) : BasePresenter<BrowseController>() {
var sources = getEnabledSources() var sources = getEnabledSources()
@ -78,7 +78,7 @@ class SourcePresenter(
} }
sourceSubscription = Observable.just(sourceItems) sourceSubscription = Observable.just(sourceItems)
.subscribeLatestCache(SourceController::setSources) .subscribeLatestCache(BrowseController::setSources)
} }
private fun loadLastUsedSource() { private fun loadLastUsedSource() {
@ -96,7 +96,7 @@ class SourcePresenter(
if (isPinned) null if (isPinned) null
else SourceItem(source, null, isPinned) else SourceItem(source, null, isPinned)
} }
}.subscribeLatestCache(SourceController::setLastUsedSource) }.subscribeLatestCache(BrowseController::setLastUsedSource)
} }
fun updateSources() { fun updateSources() {

View File

@ -31,7 +31,7 @@ import eu.kanade.tachiyomi.ui.base.controller.NucleusController
import eu.kanade.tachiyomi.ui.library.AddToLibraryCategoriesDialog import eu.kanade.tachiyomi.ui.library.AddToLibraryCategoriesDialog
import eu.kanade.tachiyomi.ui.main.MainActivity import eu.kanade.tachiyomi.ui.main.MainActivity
import eu.kanade.tachiyomi.ui.manga.MangaDetailsController import eu.kanade.tachiyomi.ui.manga.MangaDetailsController
import eu.kanade.tachiyomi.ui.source.SourceController import eu.kanade.tachiyomi.ui.source.BrowseController
import eu.kanade.tachiyomi.ui.webview.WebViewActivity import eu.kanade.tachiyomi.ui.webview.WebViewActivity
import eu.kanade.tachiyomi.util.system.connectivityManager import eu.kanade.tachiyomi.util.system.connectivityManager
import eu.kanade.tachiyomi.util.system.dpToPx import eu.kanade.tachiyomi.util.system.dpToPx
@ -67,7 +67,7 @@ open class BrowseSourceController(bundle: Bundle) :
constructor( constructor(
source: CatalogueSource, source: CatalogueSource,
searchQuery: String? = null, searchQuery: String? = null,
smartSearchConfig: SourceController.SmartSearchConfig? = null smartSearchConfig: BrowseController.SmartSearchConfig? = null
) : this( ) : this(
Bundle().apply { Bundle().apply {
putLong(SOURCE_ID_KEY, source.id) putLong(SOURCE_ID_KEY, source.id)

View File

@ -32,7 +32,8 @@
app:layout_anchorGravity="top" app:layout_anchorGravity="top"
app:layout_anchor="@id/ext_bottom_sheet" /> app:layout_anchor="@id/ext_bottom_sheet" />
<!-- Adding bottom sheet after main content --> <!-- Adding bottom sheet after main content -->
<include layout="@layout/extensions_bottom_sheet"/> <include layout="@layout/extensions_bottom_sheet"
android:id="@+id/bottom_sheet"/>
<View <View
android:id="@+id/shadow2" android:id="@+id/shadow2"