mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-07 11:17:25 +01:00
Revert "Make controllers responsible for showing/hiding FAB"
This reverts commit 8ef548032f
.
This commit is contained in:
parent
a443dc3040
commit
0cef05dd89
@ -47,7 +47,6 @@ import eu.kanade.tachiyomi.util.view.snack
|
|||||||
import eu.kanade.tachiyomi.util.view.visible
|
import eu.kanade.tachiyomi.util.view.visible
|
||||||
import eu.kanade.tachiyomi.widget.AutofitRecyclerView
|
import eu.kanade.tachiyomi.widget.AutofitRecyclerView
|
||||||
import eu.kanade.tachiyomi.widget.EmptyView
|
import eu.kanade.tachiyomi.widget.EmptyView
|
||||||
import kotlinx.android.synthetic.main.main_activity.root_fab
|
|
||||||
import kotlinx.coroutines.Job
|
import kotlinx.coroutines.Job
|
||||||
import kotlinx.coroutines.flow.drop
|
import kotlinx.coroutines.flow.drop
|
||||||
import kotlinx.coroutines.flow.filter
|
import kotlinx.coroutines.flow.filter
|
||||||
@ -87,6 +86,7 @@ open class BrowseSourceController(bundle: Bundle) :
|
|||||||
*/
|
*/
|
||||||
private var adapter: FlexibleAdapter<IFlexible<*>>? = null
|
private var adapter: FlexibleAdapter<IFlexible<*>>? = null
|
||||||
|
|
||||||
|
private var actionFab: ExtendedFloatingActionButton? = null
|
||||||
private var actionFabScrollListener: RecyclerView.OnScrollListener? = null
|
private var actionFabScrollListener: RecyclerView.OnScrollListener? = null
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -167,21 +167,27 @@ open class BrowseSourceController(bundle: Bundle) :
|
|||||||
filterSheet?.setFilters(presenter.filterItems)
|
filterSheet?.setFilters(presenter.filterItems)
|
||||||
|
|
||||||
// TODO: [ExtendedFloatingActionButton] hide/show methods don't work properly
|
// TODO: [ExtendedFloatingActionButton] hide/show methods don't work properly
|
||||||
filterSheet?.setOnShowListener { activity!!.root_fab.gone() }
|
filterSheet?.setOnShowListener { actionFab?.gone() }
|
||||||
filterSheet?.setOnDismissListener { activity!!.root_fab.visible() }
|
filterSheet?.setOnDismissListener { actionFab?.visible() }
|
||||||
|
|
||||||
activity!!.root_fab.setOnClickListener { filterSheet?.show() }
|
actionFab?.setOnClickListener { filterSheet?.show() }
|
||||||
|
|
||||||
activity!!.root_fab.visible()
|
actionFab?.visible()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun configureFab(fab: ExtendedFloatingActionButton) {
|
override fun configureFab(fab: ExtendedFloatingActionButton) {
|
||||||
|
actionFab = fab
|
||||||
|
|
||||||
|
// Controlled by initFilterSheet()
|
||||||
|
fab.gone()
|
||||||
|
|
||||||
fab.setText(R.string.action_filter)
|
fab.setText(R.string.action_filter)
|
||||||
fab.setIconResource(R.drawable.ic_filter_list_24dp)
|
fab.setIconResource(R.drawable.ic_filter_list_24dp)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun cleanupFab(fab: ExtendedFloatingActionButton) {
|
override fun cleanupFab(fab: ExtendedFloatingActionButton) {
|
||||||
actionFabScrollListener?.let { recycler?.removeOnScrollListener(it) }
|
actionFabScrollListener?.let { recycler?.removeOnScrollListener(it) }
|
||||||
|
actionFab = null
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroyView(view: View) {
|
override fun onDestroyView(view: View) {
|
||||||
@ -190,7 +196,6 @@ open class BrowseSourceController(bundle: Bundle) :
|
|||||||
adapter = null
|
adapter = null
|
||||||
snack = null
|
snack = null
|
||||||
recycler = null
|
recycler = null
|
||||||
activity!!.root_fab.gone()
|
|
||||||
super.onDestroyView(view)
|
super.onDestroyView(view)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -242,7 +247,7 @@ open class BrowseSourceController(bundle: Bundle) :
|
|||||||
)
|
)
|
||||||
recycler.clipToPadding = false
|
recycler.clipToPadding = false
|
||||||
|
|
||||||
activity!!.root_fab.shrinkOnScroll(recycler)
|
actionFab?.shrinkOnScroll(recycler)
|
||||||
}
|
}
|
||||||
|
|
||||||
recycler.setHasFixedSize(true)
|
recycler.setHasFixedSize(true)
|
||||||
|
@ -20,11 +20,8 @@ import eu.kanade.tachiyomi.databinding.CategoriesControllerBinding
|
|||||||
import eu.kanade.tachiyomi.ui.base.controller.FabController
|
import eu.kanade.tachiyomi.ui.base.controller.FabController
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.NucleusController
|
import eu.kanade.tachiyomi.ui.base.controller.NucleusController
|
||||||
import eu.kanade.tachiyomi.util.system.toast
|
import eu.kanade.tachiyomi.util.system.toast
|
||||||
import eu.kanade.tachiyomi.util.view.gone
|
|
||||||
import eu.kanade.tachiyomi.util.view.shrinkOnScroll
|
import eu.kanade.tachiyomi.util.view.shrinkOnScroll
|
||||||
import eu.kanade.tachiyomi.util.view.visible
|
|
||||||
import kotlinx.android.synthetic.main.main_activity.root_coordinator
|
import kotlinx.android.synthetic.main.main_activity.root_coordinator
|
||||||
import kotlinx.android.synthetic.main.main_activity.root_fab
|
|
||||||
import kotlinx.coroutines.flow.launchIn
|
import kotlinx.coroutines.flow.launchIn
|
||||||
import kotlinx.coroutines.flow.onEach
|
import kotlinx.coroutines.flow.onEach
|
||||||
import reactivecircus.flowbinding.android.view.clicks
|
import reactivecircus.flowbinding.android.view.clicks
|
||||||
@ -53,6 +50,7 @@ class CategoryController :
|
|||||||
*/
|
*/
|
||||||
private var adapter: CategoryAdapter? = null
|
private var adapter: CategoryAdapter? = null
|
||||||
|
|
||||||
|
private var actionFab: ExtendedFloatingActionButton? = null
|
||||||
private var actionFabScrollListener: RecyclerView.OnScrollListener? = null
|
private var actionFabScrollListener: RecyclerView.OnScrollListener? = null
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -98,11 +96,11 @@ class CategoryController :
|
|||||||
adapter?.isHandleDragEnabled = true
|
adapter?.isHandleDragEnabled = true
|
||||||
adapter?.isPermanentDelete = false
|
adapter?.isPermanentDelete = false
|
||||||
|
|
||||||
activity!!.root_fab.visible()
|
actionFabScrollListener = actionFab?.shrinkOnScroll(binding.recycler)
|
||||||
actionFabScrollListener = activity!!.root_fab.shrinkOnScroll(binding.recycler)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun configureFab(fab: ExtendedFloatingActionButton) {
|
override fun configureFab(fab: ExtendedFloatingActionButton) {
|
||||||
|
actionFab = fab
|
||||||
fab.setText(R.string.action_add)
|
fab.setText(R.string.action_add)
|
||||||
fab.setIconResource(R.drawable.ic_add_24dp)
|
fab.setIconResource(R.drawable.ic_add_24dp)
|
||||||
fab.clicks()
|
fab.clicks()
|
||||||
@ -114,6 +112,7 @@ class CategoryController :
|
|||||||
|
|
||||||
override fun cleanupFab(fab: ExtendedFloatingActionButton) {
|
override fun cleanupFab(fab: ExtendedFloatingActionButton) {
|
||||||
actionFabScrollListener?.let { binding.recycler.removeOnScrollListener(it) }
|
actionFabScrollListener?.let { binding.recycler.removeOnScrollListener(it) }
|
||||||
|
actionFab = null
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -127,7 +126,6 @@ class CategoryController :
|
|||||||
undoHelper = null
|
undoHelper = null
|
||||||
actionMode = null
|
actionMode = null
|
||||||
adapter = null
|
adapter = null
|
||||||
activity!!.root_fab.gone()
|
|
||||||
super.onDestroyView(view)
|
super.onDestroyView(view)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,6 @@ import eu.kanade.tachiyomi.util.view.gone
|
|||||||
import eu.kanade.tachiyomi.util.view.shrinkOnScroll
|
import eu.kanade.tachiyomi.util.view.shrinkOnScroll
|
||||||
import eu.kanade.tachiyomi.util.view.visible
|
import eu.kanade.tachiyomi.util.view.visible
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
import kotlinx.android.synthetic.main.main_activity.root_fab
|
|
||||||
import kotlinx.coroutines.flow.launchIn
|
import kotlinx.coroutines.flow.launchIn
|
||||||
import kotlinx.coroutines.flow.onEach
|
import kotlinx.coroutines.flow.onEach
|
||||||
import reactivecircus.flowbinding.android.view.clicks
|
import reactivecircus.flowbinding.android.view.clicks
|
||||||
@ -42,6 +41,7 @@ class DownloadController :
|
|||||||
*/
|
*/
|
||||||
private var adapter: DownloadAdapter? = null
|
private var adapter: DownloadAdapter? = null
|
||||||
|
|
||||||
|
private var actionFab: ExtendedFloatingActionButton? = null
|
||||||
private var actionFabScrollListener: RecyclerView.OnScrollListener? = null
|
private var actionFabScrollListener: RecyclerView.OnScrollListener? = null
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -87,8 +87,7 @@ class DownloadController :
|
|||||||
binding.recycler.layoutManager = LinearLayoutManager(view.context)
|
binding.recycler.layoutManager = LinearLayoutManager(view.context)
|
||||||
binding.recycler.setHasFixedSize(true)
|
binding.recycler.setHasFixedSize(true)
|
||||||
|
|
||||||
activity!!.root_fab.visible()
|
actionFabScrollListener = actionFab?.shrinkOnScroll(binding.recycler)
|
||||||
actionFabScrollListener = activity!!.root_fab.shrinkOnScroll(binding.recycler)
|
|
||||||
|
|
||||||
// Subscribe to changes
|
// Subscribe to changes
|
||||||
DownloadService.runningRelay
|
DownloadService.runningRelay
|
||||||
@ -105,6 +104,7 @@ class DownloadController :
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun configureFab(fab: ExtendedFloatingActionButton) {
|
override fun configureFab(fab: ExtendedFloatingActionButton) {
|
||||||
|
actionFab = fab
|
||||||
fab.clicks()
|
fab.clicks()
|
||||||
.onEach {
|
.onEach {
|
||||||
val context = applicationContext ?: return@onEach
|
val context = applicationContext ?: return@onEach
|
||||||
@ -123,6 +123,7 @@ class DownloadController :
|
|||||||
|
|
||||||
override fun cleanupFab(fab: ExtendedFloatingActionButton) {
|
override fun cleanupFab(fab: ExtendedFloatingActionButton) {
|
||||||
actionFabScrollListener?.let { binding.recycler.removeOnScrollListener(it) }
|
actionFabScrollListener?.let { binding.recycler.removeOnScrollListener(it) }
|
||||||
|
actionFab = null
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroyView(view: View) {
|
override fun onDestroyView(view: View) {
|
||||||
@ -130,7 +131,6 @@ class DownloadController :
|
|||||||
subscription.unsubscribe()
|
subscription.unsubscribe()
|
||||||
}
|
}
|
||||||
progressSubscriptions.clear()
|
progressSubscriptions.clear()
|
||||||
activity!!.root_fab.gone()
|
|
||||||
adapter = null
|
adapter = null
|
||||||
super.onDestroyView(view)
|
super.onDestroyView(view)
|
||||||
}
|
}
|
||||||
@ -284,10 +284,10 @@ class DownloadController :
|
|||||||
private fun setInformationView() {
|
private fun setInformationView() {
|
||||||
if (presenter.downloadQueue.isEmpty()) {
|
if (presenter.downloadQueue.isEmpty()) {
|
||||||
binding.emptyView.show(R.string.information_no_downloads)
|
binding.emptyView.show(R.string.information_no_downloads)
|
||||||
activity!!.root_fab.gone()
|
actionFab?.gone()
|
||||||
} else {
|
} else {
|
||||||
binding.emptyView.hide()
|
binding.emptyView.hide()
|
||||||
activity!!.root_fab.apply {
|
actionFab?.apply {
|
||||||
visible()
|
visible()
|
||||||
|
|
||||||
setText(
|
setText(
|
||||||
|
@ -43,6 +43,7 @@ import eu.kanade.tachiyomi.ui.recent.updates.UpdatesController
|
|||||||
import eu.kanade.tachiyomi.util.lang.launchIO
|
import eu.kanade.tachiyomi.util.lang.launchIO
|
||||||
import eu.kanade.tachiyomi.util.lang.launchUI
|
import eu.kanade.tachiyomi.util.lang.launchUI
|
||||||
import eu.kanade.tachiyomi.util.system.toast
|
import eu.kanade.tachiyomi.util.system.toast
|
||||||
|
import eu.kanade.tachiyomi.util.view.gone
|
||||||
import eu.kanade.tachiyomi.util.view.snack
|
import eu.kanade.tachiyomi.util.view.snack
|
||||||
import eu.kanade.tachiyomi.util.view.visible
|
import eu.kanade.tachiyomi.util.view.visible
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
@ -348,9 +349,11 @@ class MainActivity : BaseActivity<MainActivityBinding>() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (from is FabController) {
|
if (from is FabController) {
|
||||||
|
binding.rootFab.gone()
|
||||||
from.cleanupFab(binding.rootFab)
|
from.cleanupFab(binding.rootFab)
|
||||||
}
|
}
|
||||||
if (to is FabController) {
|
if (to is FabController) {
|
||||||
|
binding.rootFab.visible()
|
||||||
to.configureFab(binding.rootFab)
|
to.configureFab(binding.rootFab)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +68,6 @@ import eu.kanade.tachiyomi.util.view.shrinkOnScroll
|
|||||||
import eu.kanade.tachiyomi.util.view.snack
|
import eu.kanade.tachiyomi.util.view.snack
|
||||||
import eu.kanade.tachiyomi.util.view.visible
|
import eu.kanade.tachiyomi.util.view.visible
|
||||||
import kotlinx.android.synthetic.main.main_activity.root_coordinator
|
import kotlinx.android.synthetic.main.main_activity.root_coordinator
|
||||||
import kotlinx.android.synthetic.main.main_activity.root_fab
|
|
||||||
import kotlinx.coroutines.flow.launchIn
|
import kotlinx.coroutines.flow.launchIn
|
||||||
import kotlinx.coroutines.flow.onEach
|
import kotlinx.coroutines.flow.onEach
|
||||||
import reactivecircus.flowbinding.android.view.clicks
|
import reactivecircus.flowbinding.android.view.clicks
|
||||||
@ -128,6 +127,7 @@ class MangaController :
|
|||||||
*/
|
*/
|
||||||
private var settingsSheet: ChaptersSettingsSheet? = null
|
private var settingsSheet: ChaptersSettingsSheet? = null
|
||||||
|
|
||||||
|
private var actionFab: ExtendedFloatingActionButton? = null
|
||||||
private var actionFabScrollListener: RecyclerView.OnScrollListener? = null
|
private var actionFabScrollListener: RecyclerView.OnScrollListener? = null
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -191,8 +191,7 @@ class MangaController :
|
|||||||
binding.recycler.setHasFixedSize(true)
|
binding.recycler.setHasFixedSize(true)
|
||||||
chaptersAdapter?.fastScroller = binding.fastScroller
|
chaptersAdapter?.fastScroller = binding.fastScroller
|
||||||
|
|
||||||
activity!!.root_fab.visible()
|
actionFabScrollListener = actionFab?.shrinkOnScroll(binding.recycler)
|
||||||
actionFabScrollListener = activity!!.root_fab.shrinkOnScroll(binding.recycler)
|
|
||||||
|
|
||||||
// Skips directly to chapters list if navigated to from the library
|
// Skips directly to chapters list if navigated to from the library
|
||||||
binding.recycler.post {
|
binding.recycler.post {
|
||||||
@ -225,6 +224,7 @@ class MangaController :
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun configureFab(fab: ExtendedFloatingActionButton) {
|
override fun configureFab(fab: ExtendedFloatingActionButton) {
|
||||||
|
actionFab = fab
|
||||||
fab.setText(R.string.action_start)
|
fab.setText(R.string.action_start)
|
||||||
fab.setIconResource(R.drawable.ic_play_arrow_24dp)
|
fab.setIconResource(R.drawable.ic_play_arrow_24dp)
|
||||||
fab.clicks()
|
fab.clicks()
|
||||||
@ -239,7 +239,7 @@ class MangaController :
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get coordinates and start animation
|
// Get coordinates and start animation
|
||||||
val coordinates = fab.getCoordinates()
|
actionFab?.getCoordinates()?.let { coordinates ->
|
||||||
if (!binding.revealView.showRevealEffect(
|
if (!binding.revealView.showRevealEffect(
|
||||||
coordinates.x,
|
coordinates.x,
|
||||||
coordinates.y,
|
coordinates.y,
|
||||||
@ -248,6 +248,7 @@ class MangaController :
|
|||||||
) {
|
) {
|
||||||
openChapter(item.chapter)
|
openChapter(item.chapter)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
view?.context?.toast(R.string.no_next_chapter)
|
view?.context?.toast(R.string.no_next_chapter)
|
||||||
}
|
}
|
||||||
@ -257,12 +258,12 @@ class MangaController :
|
|||||||
|
|
||||||
override fun cleanupFab(fab: ExtendedFloatingActionButton) {
|
override fun cleanupFab(fab: ExtendedFloatingActionButton) {
|
||||||
actionFabScrollListener?.let { binding.recycler.removeOnScrollListener(it) }
|
actionFabScrollListener?.let { binding.recycler.removeOnScrollListener(it) }
|
||||||
|
actionFab = null
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroyView(view: View) {
|
override fun onDestroyView(view: View) {
|
||||||
destroyActionModeIfNeeded()
|
destroyActionModeIfNeeded()
|
||||||
binding.actionToolbar.destroy()
|
binding.actionToolbar.destroy()
|
||||||
activity!!.root_fab.gone()
|
|
||||||
mangaInfoAdapter = null
|
mangaInfoAdapter = null
|
||||||
chaptersHeaderAdapter = null
|
chaptersHeaderAdapter = null
|
||||||
chaptersAdapter = null
|
chaptersAdapter = null
|
||||||
@ -276,9 +277,10 @@ class MangaController :
|
|||||||
// Check if animation view is visible
|
// Check if animation view is visible
|
||||||
if (binding.revealView.visibility == View.VISIBLE) {
|
if (binding.revealView.visibility == View.VISIBLE) {
|
||||||
// Show the unreveal effect
|
// Show the unreveal effect
|
||||||
val coordinates = activity.root_fab.getCoordinates()
|
actionFab?.getCoordinates()?.let { coordinates ->
|
||||||
binding.revealView.hideRevealEffect(coordinates.x, coordinates.y, 1920)
|
binding.revealView.hideRevealEffect(coordinates.x, coordinates.y, 1920)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
super.onActivityResumed(activity)
|
super.onActivityResumed(activity)
|
||||||
}
|
}
|
||||||
@ -619,7 +621,7 @@ class MangaController :
|
|||||||
|
|
||||||
val context = view?.context
|
val context = view?.context
|
||||||
if (context != null && chapters.any { it.read }) {
|
if (context != null && chapters.any { it.read }) {
|
||||||
activity!!.root_fab.text = context.getString(R.string.action_resume)
|
actionFab?.text = context.getString(R.string.action_resume)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -759,8 +761,8 @@ class MangaController :
|
|||||||
binding.actionToolbar.findItem(R.id.action_mark_as_unread)?.isVisible = chapters.all { it.chapter.read }
|
binding.actionToolbar.findItem(R.id.action_mark_as_unread)?.isVisible = chapters.all { it.chapter.read }
|
||||||
|
|
||||||
// Hide FAB to avoid interfering with the bottom action toolbar
|
// Hide FAB to avoid interfering with the bottom action toolbar
|
||||||
// activity!!.root_fab.hide()
|
// actionFab?.hide()
|
||||||
activity!!.root_fab.gone()
|
actionFab?.gone()
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -794,8 +796,8 @@ class MangaController :
|
|||||||
|
|
||||||
// TODO: there seems to be a bug in MaterialComponents where the [ExtendedFloatingActionButton]
|
// TODO: there seems to be a bug in MaterialComponents where the [ExtendedFloatingActionButton]
|
||||||
// fails to show up properly
|
// fails to show up properly
|
||||||
// activity!!.root_fab.show()
|
// actionFab?.show()
|
||||||
activity!!.root_fab.visible()
|
actionFab?.visible()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDetach(view: View) {
|
override fun onDetach(view: View) {
|
||||||
|
Loading…
Reference in New Issue
Block a user