Merge sources and extensions into one view

This commit is contained in:
arkon 2020-04-27 19:16:46 -04:00
parent f97f4c68ba
commit d593362ba8
71 changed files with 262 additions and 191 deletions

View File

@ -38,8 +38,8 @@
android:icon="@drawable/sc_explore_48dp"
android:shortcutDisabledMessage="@string/app_not_available"
android:shortcutId="show_catalogues"
android:shortcutLongLabel="@string/label_sources"
android:shortcutShortLabel="@string/label_sources">
android:shortcutLongLabel="@string/browse"
android:shortcutShortLabel="@string/browse">
<intent
android:action="eu.kanade.tachiyomi.SHOW_CATALOGUES"
android:targetClass="eu.kanade.tachiyomi.ui.main.MainActivity" />

View File

@ -0,0 +1,145 @@
package eu.kanade.tachiyomi.ui.browse
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.bluelinelabs.conductor.Controller
import com.bluelinelabs.conductor.ControllerChangeHandler
import com.bluelinelabs.conductor.ControllerChangeType
import com.bluelinelabs.conductor.Router
import com.bluelinelabs.conductor.RouterTransaction
import com.bluelinelabs.conductor.support.RouterPagerAdapter
import com.google.android.material.badge.BadgeDrawable
import com.google.android.material.tabs.TabLayout
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
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.source.SourceController
import kotlinx.android.synthetic.main.main_activity.tabs
import uy.kohesive.injekt.injectLazy
class BrowseController :
RxController<PagerControllerBinding>,
RootController,
TabbedController {
constructor(toExtensions: Boolean = false) : super(
Bundle().apply {
putBoolean(TO_EXTENSIONS_EXTRA, toExtensions)
}
)
@Suppress("unused")
constructor(bundle: Bundle) : this(bundle.getBoolean(TO_EXTENSIONS_EXTRA))
private val preferences: PreferencesHelper by injectLazy()
private val toExtensions = args.getBoolean(TO_EXTENSIONS_EXTRA, false)
private var adapter: BrowseAdapter? = null
override fun getTitle(): String? {
return resources!!.getString(R.string.browse)
}
override fun inflateView(inflater: LayoutInflater, container: ViewGroup): View {
binding = PagerControllerBinding.inflate(inflater)
return binding.root
}
override fun onViewCreated(view: View) {
super.onViewCreated(view)
adapter = BrowseAdapter()
binding.pager.adapter = adapter
if (toExtensions) {
binding.pager.currentItem = EXTENSIONS_CONTROLLER
}
}
override fun onDestroyView(view: View) {
super.onDestroyView(view)
adapter = null
}
override fun onChangeStarted(handler: ControllerChangeHandler, type: ControllerChangeType) {
super.onChangeStarted(handler, type)
if (type.isEnter) {
activity?.tabs?.apply {
setupWithViewPager(binding.pager)
// Show badge on tab for extension updates
setExtensionUpdateBadge()
}
}
}
override fun configureTabs(tabs: TabLayout) {
with(tabs) {
tabGravity = TabLayout.GRAVITY_FILL
tabMode = TabLayout.MODE_FIXED
}
}
override fun cleanupTabs(tabs: TabLayout) {
// Remove extension update badge
tabs.getTabAt(EXTENSIONS_CONTROLLER)?.removeBadge()
}
fun pushController(transaction: RouterTransaction) {
router.pushController(transaction)
}
fun setExtensionUpdateBadge() {
activity?.tabs?.apply {
val updates = preferences.extensionUpdatesCount().get()
if (updates > 0) {
val badge: BadgeDrawable = getTabAt(1)!!.orCreateBadge
badge.isVisible = true
} else {
getTabAt(EXTENSIONS_CONTROLLER)!!.removeBadge()
}
}
}
private inner class BrowseAdapter : RouterPagerAdapter(this@BrowseController) {
private val tabTitles = listOf(
R.string.label_sources,
R.string.label_extensions
)
.map { resources!!.getString(it) }
override fun getCount(): Int {
return tabTitles.size
}
override fun configureRouter(router: Router, position: Int) {
if (!router.hasRootController()) {
val controller: Controller = when (position) {
SOURCES_CONTROLLER -> SourceController()
EXTENSIONS_CONTROLLER -> ExtensionController()
else -> error("Wrong position $position")
}
router.setRoot(RouterTransaction.with(controller))
}
}
override fun getPageTitle(position: Int): CharSequence {
return tabTitles[position]
}
}
companion object {
const val TO_EXTENSIONS_EXTRA = "to_extensions"
const val SOURCES_CONTROLLER = 0
const val EXTENSIONS_CONTROLLER = 1
}
}

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.extension
package eu.kanade.tachiyomi.ui.browse.extension
import eu.davidea.flexibleadapter.FlexibleAdapter
import eu.davidea.flexibleadapter.items.IFlexible

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.extension
package eu.kanade.tachiyomi.ui.browse.extension
import android.view.LayoutInflater
import android.view.Menu
@ -21,6 +21,7 @@ import eu.kanade.tachiyomi.extension.ExtensionUpdateJob
import eu.kanade.tachiyomi.extension.model.Extension
import eu.kanade.tachiyomi.ui.base.controller.NucleusController
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
import eu.kanade.tachiyomi.ui.browse.BrowseController
import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
@ -93,7 +94,7 @@ open class ExtensionController :
when (item.itemId) {
R.id.action_search -> expandActionViewFromInteraction = true
R.id.action_settings -> {
router.pushController(
(parentController as BrowseController).pushController(
(RouterTransaction.with(ExtensionFilterController()))
.popChangeHandler(SettingsExtensionsFadeChangeHandler())
.pushChangeHandler(FadeChangeHandler())
@ -182,7 +183,7 @@ open class ExtensionController :
private fun openDetails(extension: Extension.Installed) {
val controller = ExtensionDetailsController(extension.pkgName)
router.pushController(controller.withFadeTransaction())
(parentController as BrowseController).pushController(controller.withFadeTransaction())
}
private fun openTrustDialog(extension: Extension.Untrusted) {
@ -194,6 +195,9 @@ open class ExtensionController :
binding.extSwipeRefresh.isRefreshing = false
this.extensions = extensions
drawExtensions()
// Update badge on parent controller tab
(parentController as BrowseController).setExtensionUpdateBadge()
}
fun drawExtensions() {

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.extension
package eu.kanade.tachiyomi.ui.browse.extension
import android.annotation.SuppressLint
import android.content.Context

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.extension
package eu.kanade.tachiyomi.ui.browse.extension
import android.os.Bundle
import eu.kanade.tachiyomi.extension.ExtensionManager

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.extension
package eu.kanade.tachiyomi.ui.browse.extension
import android.content.Context
import android.graphics.Canvas

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.extension
package eu.kanade.tachiyomi.ui.browse.extension
import androidx.preference.PreferenceScreen
import eu.kanade.tachiyomi.R

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.extension
package eu.kanade.tachiyomi.ui.browse.extension
import android.annotation.SuppressLint
import android.view.View

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.extension
package eu.kanade.tachiyomi.ui.browse.extension
import android.view.View
import androidx.recyclerview.widget.RecyclerView

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.extension
package eu.kanade.tachiyomi.ui.browse.extension
import android.view.View
import eu.kanade.tachiyomi.R

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.extension
package eu.kanade.tachiyomi.ui.browse.extension
import android.view.View
import androidx.recyclerview.widget.RecyclerView

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.extension
package eu.kanade.tachiyomi.ui.browse.extension
import android.app.Application
import android.os.Bundle

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.extension
package eu.kanade.tachiyomi.ui.browse.extension
import android.app.Dialog
import android.os.Bundle

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.extension
package eu.kanade.tachiyomi.ui.browse.extension
import android.content.Context
import android.content.pm.PackageManager

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.source
package eu.kanade.tachiyomi.ui.browse.source
import android.view.View
import eu.davidea.flexibleadapter.FlexibleAdapter

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.source
package eu.kanade.tachiyomi.ui.browse.source
import android.view.View
import androidx.recyclerview.widget.RecyclerView

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.source
package eu.kanade.tachiyomi.ui.browse.source
import eu.davidea.flexibleadapter.FlexibleAdapter
import eu.davidea.flexibleadapter.items.IFlexible

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.source
package eu.kanade.tachiyomi.ui.browse.source
import android.Manifest.permission.WRITE_EXTERNAL_STORAGE
import android.view.LayoutInflater
@ -23,13 +23,13 @@ import eu.kanade.tachiyomi.databinding.SourceMainControllerBinding
import eu.kanade.tachiyomi.source.CatalogueSource
import eu.kanade.tachiyomi.source.Source
import eu.kanade.tachiyomi.ui.base.controller.NucleusController
import eu.kanade.tachiyomi.ui.base.controller.RootController
import eu.kanade.tachiyomi.ui.base.controller.requestPermissionsSafe
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
import eu.kanade.tachiyomi.ui.browse.BrowseController
import eu.kanade.tachiyomi.ui.browse.source.browse.BrowseSourceController
import eu.kanade.tachiyomi.ui.browse.source.globalsearch.GlobalSearchController
import eu.kanade.tachiyomi.ui.browse.source.latest.LatestUpdatesController
import eu.kanade.tachiyomi.ui.setting.SettingsSourcesController
import eu.kanade.tachiyomi.ui.source.browse.BrowseSourceController
import eu.kanade.tachiyomi.ui.source.globalsearch.GlobalSearchController
import eu.kanade.tachiyomi.ui.source.latest.LatestUpdatesController
import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
@ -46,7 +46,6 @@ import uy.kohesive.injekt.api.get
*/
class SourceController :
NucleusController<SourceMainControllerBinding, SourcePresenter>(),
RootController,
FlexibleAdapter.OnItemClickListener,
FlexibleAdapter.OnItemLongClickListener,
SourceAdapter.OnBrowseClickListener,
@ -178,7 +177,7 @@ class SourceController :
*/
private fun openCatalogue(source: CatalogueSource, controller: BrowseSourceController) {
preferences.lastUsedCatalogueSource().set(source.id)
router.pushController(controller.withFadeTransaction())
(parentController as BrowseController).pushController(controller.withFadeTransaction())
}
/**
@ -206,7 +205,7 @@ class SourceController :
}
fun performGlobalSearch(query: String) {
router.pushController(GlobalSearchController(query).withFadeTransaction())
(parentController as BrowseController).pushController(GlobalSearchController(query).withFadeTransaction())
}
/**
@ -219,7 +218,7 @@ class SourceController :
when (item.itemId) {
// Initialize option to open catalogue settings.
R.id.action_settings -> {
router.pushController(
(parentController as BrowseController).pushController(
(RouterTransaction.with(SettingsSourcesController()))
.popChangeHandler(SettingsSourcesFadeChangeHandler())
.pushChangeHandler(FadeChangeHandler())

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.source
package eu.kanade.tachiyomi.ui.browse.source
import android.content.Context
import android.graphics.Canvas

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.source
package eu.kanade.tachiyomi.ui.browse.source
import android.view.View
import eu.kanade.tachiyomi.R

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.source
package eu.kanade.tachiyomi.ui.browse.source
import android.view.View
import androidx.recyclerview.widget.RecyclerView

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.source
package eu.kanade.tachiyomi.ui.browse.source
import android.os.Bundle
import eu.kanade.tachiyomi.data.preference.PreferencesHelper

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.source.browse
package eu.kanade.tachiyomi.ui.browse.source.browse
import android.content.res.Configuration
import android.os.Bundle

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.source.browse
package eu.kanade.tachiyomi.ui.browse.source.browse
import android.os.Bundle
import eu.davidea.flexibleadapter.items.IFlexible
@ -15,19 +15,19 @@ import eu.kanade.tachiyomi.source.model.Filter
import eu.kanade.tachiyomi.source.model.FilterList
import eu.kanade.tachiyomi.source.model.SManga
import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter
import eu.kanade.tachiyomi.ui.source.filter.CheckboxItem
import eu.kanade.tachiyomi.ui.source.filter.CheckboxSectionItem
import eu.kanade.tachiyomi.ui.source.filter.GroupItem
import eu.kanade.tachiyomi.ui.source.filter.HeaderItem
import eu.kanade.tachiyomi.ui.source.filter.SelectItem
import eu.kanade.tachiyomi.ui.source.filter.SelectSectionItem
import eu.kanade.tachiyomi.ui.source.filter.SeparatorItem
import eu.kanade.tachiyomi.ui.source.filter.SortGroup
import eu.kanade.tachiyomi.ui.source.filter.SortItem
import eu.kanade.tachiyomi.ui.source.filter.TextItem
import eu.kanade.tachiyomi.ui.source.filter.TextSectionItem
import eu.kanade.tachiyomi.ui.source.filter.TriStateItem
import eu.kanade.tachiyomi.ui.source.filter.TriStateSectionItem
import eu.kanade.tachiyomi.ui.browse.source.filter.CheckboxItem
import eu.kanade.tachiyomi.ui.browse.source.filter.CheckboxSectionItem
import eu.kanade.tachiyomi.ui.browse.source.filter.GroupItem
import eu.kanade.tachiyomi.ui.browse.source.filter.HeaderItem
import eu.kanade.tachiyomi.ui.browse.source.filter.SelectItem
import eu.kanade.tachiyomi.ui.browse.source.filter.SelectSectionItem
import eu.kanade.tachiyomi.ui.browse.source.filter.SeparatorItem
import eu.kanade.tachiyomi.ui.browse.source.filter.SortGroup
import eu.kanade.tachiyomi.ui.browse.source.filter.SortItem
import eu.kanade.tachiyomi.ui.browse.source.filter.TextItem
import eu.kanade.tachiyomi.ui.browse.source.filter.TextSectionItem
import eu.kanade.tachiyomi.ui.browse.source.filter.TriStateItem
import eu.kanade.tachiyomi.ui.browse.source.filter.TriStateSectionItem
import rx.Observable
import rx.Subscription
import rx.android.schedulers.AndroidSchedulers

View File

@ -0,0 +1,3 @@
package eu.kanade.tachiyomi.ui.browse.source.browse
class NoResultsException : Exception()

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.source.browse
package eu.kanade.tachiyomi.ui.browse.source.browse
import com.jakewharton.rxrelay.PublishRelay
import eu.kanade.tachiyomi.source.model.MangasPage

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.source.browse
package eu.kanade.tachiyomi.ui.browse.source.browse
import android.view.View
import android.widget.ProgressBar

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.source.browse
package eu.kanade.tachiyomi.ui.browse.source.browse
import android.app.Activity
import android.content.Context

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.source.browse
package eu.kanade.tachiyomi.ui.browse.source.browse
import android.view.View
import com.bumptech.glide.load.engine.DiskCacheStrategy

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.source.browse
package eu.kanade.tachiyomi.ui.browse.source.browse
import android.view.View
import eu.davidea.flexibleadapter.FlexibleAdapter

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.source.browse
package eu.kanade.tachiyomi.ui.browse.source.browse
import android.view.Gravity
import android.view.View

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.source.browse
package eu.kanade.tachiyomi.ui.browse.source.browse
import android.view.View
import com.bumptech.glide.load.engine.DiskCacheStrategy

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.source.browse
package eu.kanade.tachiyomi.ui.browse.source.browse
import eu.kanade.tachiyomi.source.CatalogueSource
import eu.kanade.tachiyomi.source.model.FilterList

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.source.filter
package eu.kanade.tachiyomi.ui.browse.source.filter
import android.view.View
import android.widget.CheckBox

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.source.filter
package eu.kanade.tachiyomi.ui.browse.source.filter
import android.view.View
import android.widget.ImageView

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.source.filter
package eu.kanade.tachiyomi.ui.browse.source.filter
import android.annotation.SuppressLint
import android.view.View

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.source.filter
package eu.kanade.tachiyomi.ui.browse.source.filter
import eu.davidea.flexibleadapter.items.ISectionable
import eu.kanade.tachiyomi.source.model.Filter

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.source.filter
package eu.kanade.tachiyomi.ui.browse.source.filter
import android.view.View
import android.widget.ArrayAdapter

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.source.filter
package eu.kanade.tachiyomi.ui.browse.source.filter
import android.annotation.SuppressLint
import android.view.View

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.source.filter
package eu.kanade.tachiyomi.ui.browse.source.filter
import android.view.View
import androidx.recyclerview.widget.RecyclerView

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.source.filter
package eu.kanade.tachiyomi.ui.browse.source.filter
import android.view.View
import android.widget.CheckedTextView

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.source.filter
package eu.kanade.tachiyomi.ui.browse.source.filter
import android.view.View
import android.widget.EditText

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.source.filter
package eu.kanade.tachiyomi.ui.browse.source.filter
import android.view.View
import android.widget.CheckedTextView

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.source.globalsearch
package eu.kanade.tachiyomi.ui.browse.source.globalsearch
import android.os.Bundle
import android.os.Parcelable

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.source.globalsearch
package eu.kanade.tachiyomi.ui.browse.source.globalsearch
import eu.davidea.flexibleadapter.FlexibleAdapter
import eu.kanade.tachiyomi.data.database.models.Manga

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.source.globalsearch
package eu.kanade.tachiyomi.ui.browse.source.globalsearch
import android.view.View
import com.bumptech.glide.load.engine.DiskCacheStrategy

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.source.globalsearch
package eu.kanade.tachiyomi.ui.browse.source.globalsearch
import android.view.View
import androidx.recyclerview.widget.RecyclerView

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.source.globalsearch
package eu.kanade.tachiyomi.ui.browse.source.globalsearch
import android.os.Bundle
import android.view.LayoutInflater

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.source.globalsearch
package eu.kanade.tachiyomi.ui.browse.source.globalsearch
import android.view.View
import androidx.recyclerview.widget.LinearLayoutManager

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.source.globalsearch
package eu.kanade.tachiyomi.ui.browse.source.globalsearch
import android.view.View
import androidx.recyclerview.widget.RecyclerView

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.ui.source.globalsearch
package eu.kanade.tachiyomi.ui.browse.source.globalsearch
import android.os.Bundle
import eu.kanade.tachiyomi.data.database.DatabaseHelper
@ -12,7 +12,7 @@ import eu.kanade.tachiyomi.source.model.FilterList
import eu.kanade.tachiyomi.source.model.MangasPage
import eu.kanade.tachiyomi.source.model.SManga
import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter
import eu.kanade.tachiyomi.ui.source.browse.BrowseSourcePresenter
import eu.kanade.tachiyomi.ui.browse.source.browse.BrowseSourcePresenter
import rx.Observable
import rx.Subscription
import rx.android.schedulers.AndroidSchedulers

View File

@ -1,11 +1,11 @@
package eu.kanade.tachiyomi.ui.source.latest
package eu.kanade.tachiyomi.ui.browse.source.latest
import android.os.Bundle
import android.view.Menu
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.source.CatalogueSource
import eu.kanade.tachiyomi.ui.source.browse.BrowseSourceController
import eu.kanade.tachiyomi.ui.source.browse.BrowseSourcePresenter
import eu.kanade.tachiyomi.ui.browse.source.browse.BrowseSourceController
import eu.kanade.tachiyomi.ui.browse.source.browse.BrowseSourcePresenter
/**
* Controller that shows the latest manga from the catalogue. Inherit [BrowseSourceController].

View File

@ -1,8 +1,8 @@
package eu.kanade.tachiyomi.ui.source.latest
package eu.kanade.tachiyomi.ui.browse.source.latest
import eu.kanade.tachiyomi.source.CatalogueSource
import eu.kanade.tachiyomi.source.model.MangasPage
import eu.kanade.tachiyomi.ui.source.browse.Pager
import eu.kanade.tachiyomi.ui.browse.source.browse.Pager
import rx.Observable
import rx.android.schedulers.AndroidSchedulers
import rx.schedulers.Schedulers

View File

@ -1,8 +1,8 @@
package eu.kanade.tachiyomi.ui.source.latest
package eu.kanade.tachiyomi.ui.browse.source.latest
import eu.kanade.tachiyomi.source.model.FilterList
import eu.kanade.tachiyomi.ui.source.browse.BrowseSourcePresenter
import eu.kanade.tachiyomi.ui.source.browse.Pager
import eu.kanade.tachiyomi.ui.browse.source.browse.BrowseSourcePresenter
import eu.kanade.tachiyomi.ui.browse.source.browse.Pager
/**
* Presenter of [LatestUpdatesController]. Inherit BrowseCataloguePresenter.

View File

@ -21,15 +21,14 @@ import eu.kanade.tachiyomi.ui.base.controller.NoToolbarElevationController
import eu.kanade.tachiyomi.ui.base.controller.RootController
import eu.kanade.tachiyomi.ui.base.controller.TabbedController
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
import eu.kanade.tachiyomi.ui.browse.BrowseController
import eu.kanade.tachiyomi.ui.browse.source.globalsearch.GlobalSearchController
import eu.kanade.tachiyomi.ui.download.DownloadController
import eu.kanade.tachiyomi.ui.extension.ExtensionController
import eu.kanade.tachiyomi.ui.library.LibraryController
import eu.kanade.tachiyomi.ui.manga.MangaController
import eu.kanade.tachiyomi.ui.more.MoreController
import eu.kanade.tachiyomi.ui.recent.history.HistoryController
import eu.kanade.tachiyomi.ui.recent.updates.UpdatesController
import eu.kanade.tachiyomi.ui.source.SourceController
import eu.kanade.tachiyomi.ui.source.globalsearch.GlobalSearchController
import eu.kanade.tachiyomi.util.lang.launchUI
import eu.kanade.tachiyomi.util.system.WebViewUtil
import eu.kanade.tachiyomi.util.system.toast
@ -95,7 +94,7 @@ class MainActivity : BaseActivity<MainActivityBinding>() {
R.id.nav_library -> setRoot(LibraryController(), id)
R.id.nav_updates -> setRoot(UpdatesController(), id)
R.id.nav_history -> setRoot(HistoryController(), id)
R.id.nav_sources -> setRoot(SourceController(), id)
R.id.nav_browse -> setRoot(BrowseController(), id)
R.id.nav_more -> setRoot(MoreController(), id)
}
} else if (!isHandlingShortcut) {
@ -173,9 +172,9 @@ class MainActivity : BaseActivity<MainActivityBinding>() {
private fun setExtensionsBadge() {
val updates = preferences.extensionUpdatesCount().get()
if (updates > 0) {
binding.bottomNav.getOrCreateBadge(R.id.nav_more).number = updates
binding.bottomNav.getOrCreateBadge(R.id.nav_browse).number = updates
} else {
binding.bottomNav.removeBadge(R.id.nav_more)
binding.bottomNav.removeBadge(R.id.nav_browse)
}
}
@ -208,13 +207,13 @@ class MainActivity : BaseActivity<MainActivityBinding>() {
SHORTCUT_LIBRARY -> setSelectedNavItem(R.id.nav_library)
SHORTCUT_RECENTLY_UPDATED -> setSelectedNavItem(R.id.nav_updates)
SHORTCUT_RECENTLY_READ -> setSelectedNavItem(R.id.nav_history)
SHORTCUT_CATALOGUES -> setSelectedNavItem(R.id.nav_sources)
SHORTCUT_CATALOGUES -> setSelectedNavItem(R.id.nav_browse)
SHORTCUT_EXTENSIONS -> {
if (router.backstackSize > 1) {
router.popToRoot()
}
setSelectedNavItem(R.id.nav_more)
router.pushController(ExtensionController().withFadeTransaction())
router.pushController(BrowseController(true).withFadeTransaction())
setSelectedNavItem(R.id.nav_browse)
}
SHORTCUT_MANGA -> {
val extras = intent.extras ?: return false

View File

@ -18,7 +18,7 @@ import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.database.DatabaseHelper
import eu.kanade.tachiyomi.data.database.models.Manga
import eu.kanade.tachiyomi.data.track.TrackManager
import eu.kanade.tachiyomi.databinding.MangaControllerBinding
import eu.kanade.tachiyomi.databinding.PagerControllerBinding
import eu.kanade.tachiyomi.source.Source
import eu.kanade.tachiyomi.source.SourceManager
import eu.kanade.tachiyomi.ui.base.controller.RxController
@ -33,7 +33,7 @@ import rx.Subscription
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
class MangaController : RxController<MangaControllerBinding>, TabbedController {
class MangaController : RxController<PagerControllerBinding>, TabbedController {
constructor(manga: Manga?, fromSource: Boolean = false) : super(
Bundle().apply {
@ -75,7 +75,7 @@ class MangaController : RxController<MangaControllerBinding>, TabbedController {
}
override fun inflateView(inflater: LayoutInflater, container: ViewGroup): View {
binding = MangaControllerBinding.inflate(inflater)
binding = PagerControllerBinding.inflate(inflater)
return binding.root
}
@ -87,11 +87,11 @@ class MangaController : RxController<MangaControllerBinding>, TabbedController {
requestPermissionsSafe(arrayOf(WRITE_EXTERNAL_STORAGE), 301)
adapter = MangaDetailAdapter()
binding.mangaPager.offscreenPageLimit = 3
binding.mangaPager.adapter = adapter
binding.pager.offscreenPageLimit = 3
binding.pager.adapter = adapter
if (!fromSource) {
binding.mangaPager.currentItem = CHAPTERS_CONTROLLER
binding.pager.currentItem = CHAPTERS_CONTROLLER
}
}
@ -103,7 +103,7 @@ class MangaController : RxController<MangaControllerBinding>, TabbedController {
override fun onChangeStarted(handler: ControllerChangeHandler, type: ControllerChangeType) {
super.onChangeStarted(handler, type)
if (type.isEnter) {
activity?.tabs?.setupWithViewPager(binding.mangaPager)
activity?.tabs?.setupWithViewPager(binding.pager)
trackingIconSubscription = trackingIconRelay.subscribe { setTrackingIconInternal(it) }
}
}

View File

@ -21,14 +21,14 @@ import eu.kanade.tachiyomi.source.model.SManga
import eu.kanade.tachiyomi.source.online.HttpSource
import eu.kanade.tachiyomi.ui.base.controller.NucleusController
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
import eu.kanade.tachiyomi.ui.browse.source.browse.BrowseSourceController
import eu.kanade.tachiyomi.ui.browse.source.globalsearch.GlobalSearchController
import eu.kanade.tachiyomi.ui.library.ChangeMangaCategoriesDialog
import eu.kanade.tachiyomi.ui.library.LibraryController
import eu.kanade.tachiyomi.ui.main.MainActivity
import eu.kanade.tachiyomi.ui.manga.MangaController
import eu.kanade.tachiyomi.ui.recent.history.HistoryController
import eu.kanade.tachiyomi.ui.recent.updates.UpdatesController
import eu.kanade.tachiyomi.ui.source.browse.BrowseSourceController
import eu.kanade.tachiyomi.ui.source.globalsearch.GlobalSearchController
import eu.kanade.tachiyomi.ui.webview.WebViewActivity
import eu.kanade.tachiyomi.util.system.copyToClipboard
import eu.kanade.tachiyomi.util.system.toast

View File

@ -8,8 +8,8 @@ import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.database.models.Manga
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.ui.base.controller.DialogController
import eu.kanade.tachiyomi.ui.source.globalsearch.GlobalSearchController
import eu.kanade.tachiyomi.ui.source.globalsearch.GlobalSearchPresenter
import eu.kanade.tachiyomi.ui.browse.source.globalsearch.GlobalSearchController
import eu.kanade.tachiyomi.ui.browse.source.globalsearch.GlobalSearchPresenter
import eu.kanade.tachiyomi.util.view.gone
import eu.kanade.tachiyomi.util.view.visible
import uy.kohesive.injekt.injectLazy

View File

@ -8,9 +8,9 @@ import eu.kanade.tachiyomi.source.CatalogueSource
import eu.kanade.tachiyomi.source.Source
import eu.kanade.tachiyomi.source.model.SChapter
import eu.kanade.tachiyomi.source.model.SManga
import eu.kanade.tachiyomi.ui.source.globalsearch.GlobalSearchCardItem
import eu.kanade.tachiyomi.ui.source.globalsearch.GlobalSearchItem
import eu.kanade.tachiyomi.ui.source.globalsearch.GlobalSearchPresenter
import eu.kanade.tachiyomi.ui.browse.source.globalsearch.GlobalSearchCardItem
import eu.kanade.tachiyomi.ui.browse.source.globalsearch.GlobalSearchItem
import eu.kanade.tachiyomi.ui.browse.source.globalsearch.GlobalSearchPresenter
import eu.kanade.tachiyomi.util.chapter.syncChaptersWithSource
import rx.Observable
import rx.android.schedulers.AndroidSchedulers

View File

@ -3,15 +3,12 @@ package eu.kanade.tachiyomi.ui.more
import androidx.preference.PreferenceScreen
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.ui.base.controller.RootController
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
import eu.kanade.tachiyomi.ui.download.DownloadController
import eu.kanade.tachiyomi.ui.extension.ExtensionController
import eu.kanade.tachiyomi.ui.migration.MigrationController
import eu.kanade.tachiyomi.ui.setting.SettingsController
import eu.kanade.tachiyomi.ui.setting.SettingsMainController
import eu.kanade.tachiyomi.util.preference.badgePreference
import eu.kanade.tachiyomi.util.preference.iconRes
import eu.kanade.tachiyomi.util.preference.iconTint
import eu.kanade.tachiyomi.util.preference.onClick
@ -21,7 +18,6 @@ import eu.kanade.tachiyomi.util.preference.switchPreference
import eu.kanade.tachiyomi.util.preference.titleRes
import eu.kanade.tachiyomi.util.system.getResourceColor
import eu.kanade.tachiyomi.util.system.openInBrowser
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
class MoreController : SettingsController(), RootController {
@ -39,15 +35,6 @@ class MoreController : SettingsController(), RootController {
}
preferenceCategory {
badgePreference {
titleRes = R.string.label_extensions
iconRes = R.drawable.ic_extension_24dp
iconTint = tintColor
setBadge(Injekt.get<PreferencesHelper>().extensionUpdatesCount().get())
onClick {
router.pushController(ExtensionController().withFadeTransaction())
}
}
preference {
titleRes = R.string.label_download_queue
iconRes = R.drawable.ic_file_download_black_24dp

View File

@ -1,3 +0,0 @@
package eu.kanade.tachiyomi.ui.source.browse
class NoResultsException : Exception()

View File

@ -13,7 +13,6 @@ import androidx.preference.PreferenceManager
import androidx.preference.PreferenceScreen
import androidx.preference.SwitchPreferenceCompat
import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat
import eu.kanade.tachiyomi.widget.preference.BadgePreference
import eu.kanade.tachiyomi.widget.preference.IntListPreference
import eu.kanade.tachiyomi.widget.preference.SwitchPreferenceCategory
@ -57,10 +56,6 @@ inline fun PreferenceGroup.multiSelectListPreference(block: (@DSL MultiSelectLis
return initThenAdd(MultiSelectListPreference(context), block).also(::initDialog)
}
inline fun PreferenceGroup.badgePreference(block: (@DSL BadgePreference).() -> Unit): BadgePreference {
return initThenAdd(BadgePreference(context), block)
}
inline fun PreferenceScreen.preferenceCategory(block: (@DSL PreferenceCategory).() -> Unit): PreferenceCategory {
return addThenInit(PreferenceCategory(context), block)
}

View File

@ -7,7 +7,7 @@ import android.os.Build
import android.view.ContextThemeWrapper
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.ui.source.SourcePresenter
import eu.kanade.tachiyomi.ui.browse.source.SourcePresenter
import java.util.Locale
import uy.kohesive.injekt.injectLazy

View File

@ -1,37 +0,0 @@
package eu.kanade.tachiyomi.widget.preference
import android.content.Context
import android.util.AttributeSet
import androidx.preference.Preference
import androidx.preference.PreferenceViewHolder
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.util.view.gone
import eu.kanade.tachiyomi.util.view.visible
import kotlinx.android.synthetic.main.pref_badge.view.badge
class BadgePreference @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
Preference(context, attrs) {
private var badgeNumber: Int = 0
init {
widgetLayoutResource = R.layout.pref_badge
}
override fun onBindViewHolder(holder: PreferenceViewHolder) {
super.onBindViewHolder(holder)
if (badgeNumber > 0) {
holder.itemView.badge.text = badgeNumber.toString()
holder.itemView.badge.visible()
} else {
holder.itemView.badge.text = null
holder.itemView.badge.gone()
}
}
fun setBadge(number: Int) {
this.badgeNumber = number
notifyChanged()
}
}

View File

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="13dp" />
<size
android:width="25dp"
android:height="25dp" />
<solid android:color="?attr/colorError" />
</shape>

View File

@ -5,7 +5,7 @@
android:id="@id/swipe_refresh"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="eu.kanade.tachiyomi.ui.source.browse.BrowseSourceController">
tools:context=".ui.browse.source.browse.BrowseSourceController">
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.viewpager.widget.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/manga_pager"
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent" />

View File

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/badge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/round_textview_background"
android:gravity="center"
android:padding="3dp"
android:textAppearance="@style/TextAppearance.MaterialComponents.Badge"
android:textStyle="bold"
tools:text="3" />

View File

@ -14,7 +14,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="eu.kanade.tachiyomi.ui.source.browse.BrowseSourceController">
tools:context=".ui.browse.source.browse.BrowseSourceController">
<ProgressBar
android:id="@+id/progress"

View File

@ -13,9 +13,9 @@
android:icon="@drawable/ic_history_24dp"
android:title="@string/label_recent_manga" />
<item
android:id="@+id/nav_sources"
android:id="@+id/nav_browse"
android:icon="@drawable/ic_explore_state"
android:title="@string/label_sources" />
android:title="@string/browse" />
<item
android:id="@+id/nav_more"
android:icon="@drawable/ic_more_horiz_24dp"