mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-25 01:41:50 +01:00
Long pressing library icon now updates the library
Long pressing on other tab items expands the bottom sheet for that page
This commit is contained in:
parent
b67c6ec2c7
commit
3bee24e79a
@ -59,6 +59,7 @@ import eu.kanade.tachiyomi.util.system.getResourceColor
|
|||||||
import eu.kanade.tachiyomi.util.system.launchUI
|
import eu.kanade.tachiyomi.util.system.launchUI
|
||||||
import eu.kanade.tachiyomi.util.system.toast
|
import eu.kanade.tachiyomi.util.system.toast
|
||||||
import eu.kanade.tachiyomi.util.view.applyWindowInsetsForRootController
|
import eu.kanade.tachiyomi.util.view.applyWindowInsetsForRootController
|
||||||
|
import eu.kanade.tachiyomi.util.view.getItemView
|
||||||
import eu.kanade.tachiyomi.util.view.gone
|
import eu.kanade.tachiyomi.util.view.gone
|
||||||
import eu.kanade.tachiyomi.util.view.scrollViewWith
|
import eu.kanade.tachiyomi.util.view.scrollViewWith
|
||||||
import eu.kanade.tachiyomi.util.view.setOnQueryTextChangeListener
|
import eu.kanade.tachiyomi.util.view.setOnQueryTextChangeListener
|
||||||
@ -148,10 +149,10 @@ class LibraryController(
|
|||||||
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
||||||
super.onScrolled(recyclerView, dx, dy)
|
super.onScrolled(recyclerView, dx, dy)
|
||||||
val order = getCategoryOrder()
|
val order = getCategoryOrder()
|
||||||
if (bottom_sheet.canHide()) {
|
if (filter_bottom_sheet.canHide()) {
|
||||||
scrollDistance += abs(dy)
|
scrollDistance += abs(dy)
|
||||||
if (scrollDistance > scrollDistanceTilHidden) {
|
if (scrollDistance > scrollDistanceTilHidden) {
|
||||||
bottom_sheet.hideIfPossible()
|
filter_bottom_sheet.hideIfPossible()
|
||||||
scrollDistance = 0f
|
scrollDistance = 0f
|
||||||
}
|
}
|
||||||
} else scrollDistance = 0f
|
} else scrollDistance = 0f
|
||||||
@ -335,15 +336,13 @@ class LibraryController(
|
|||||||
createActionModeIfNeeded()
|
createActionModeIfNeeded()
|
||||||
}
|
}
|
||||||
|
|
||||||
bottom_sheet.onCreate(recycler_layout)
|
filter_bottom_sheet.onCreate(recycler_layout)
|
||||||
|
|
||||||
bottom_sheet.onGroupClicked = {
|
filter_bottom_sheet.onGroupClicked = {
|
||||||
when (it) {
|
when (it) {
|
||||||
FilterBottomSheet.ACTION_REFRESH -> onRefresh()
|
FilterBottomSheet.ACTION_REFRESH -> onRefresh()
|
||||||
FilterBottomSheet.ACTION_FILTER -> onFilterChanged()
|
FilterBottomSheet.ACTION_FILTER -> onFilterChanged()
|
||||||
FilterBottomSheet.ACTION_HIDE_FILTER_TIP -> activity?.toast(
|
FilterBottomSheet.ACTION_HIDE_FILTER_TIP -> showFilterTip()
|
||||||
R.string.hide_filters_tip, Toast.LENGTH_LONG
|
|
||||||
)
|
|
||||||
FilterBottomSheet.ACTION_DISPLAY -> DisplayBottomSheet(this).show()
|
FilterBottomSheet.ACTION_DISPLAY -> DisplayBottomSheet(this).show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -418,7 +417,7 @@ class LibraryController(
|
|||||||
val view = view ?: return
|
val view = view ?: return
|
||||||
LibraryUpdateService.start(view.context, category)
|
LibraryUpdateService.start(view.context, category)
|
||||||
snack = view.snack(R.string.updating_library) {
|
snack = view.snack(R.string.updating_library) {
|
||||||
anchorView = bottom_sheet
|
anchorView = filter_bottom_sheet
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -449,7 +448,7 @@ class LibraryController(
|
|||||||
DownloadService.callListeners()
|
DownloadService.callListeners()
|
||||||
LibraryUpdateService.setListener(this)
|
LibraryUpdateService.setListener(this)
|
||||||
}
|
}
|
||||||
if (type == ControllerChangeType.POP_ENTER) bottom_sheet.hideIfPossible()
|
if (type == ControllerChangeType.POP_ENTER) filter_bottom_sheet.hideIfPossible()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onActivityResumed(activity: Activity) {
|
override fun onActivityResumed(activity: Activity) {
|
||||||
@ -485,7 +484,7 @@ class LibraryController(
|
|||||||
} else {
|
} else {
|
||||||
empty_view?.show(
|
empty_view?.show(
|
||||||
R.drawable.ic_book_black_128dp,
|
R.drawable.ic_book_black_128dp,
|
||||||
if (bottom_sheet.hasActiveFilters()) R.string.no_matches_for_filters
|
if (filter_bottom_sheet.hasActiveFilters()) R.string.no_matches_for_filters
|
||||||
else R.string.library_is_empty_add_from_browse
|
else R.string.library_is_empty_add_from_browse
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -632,7 +631,7 @@ class LibraryController(
|
|||||||
|
|
||||||
override fun canDrag(): Boolean {
|
override fun canDrag(): Boolean {
|
||||||
val filterOff =
|
val filterOff =
|
||||||
!bottom_sheet.hasActiveFilters() && !preferences.hideCategories().getOrDefault()
|
!filter_bottom_sheet.hasActiveFilters() && !preferences.hideCategories().getOrDefault()
|
||||||
return filterOff && adapter.mode != SelectableAdapter.Mode.MULTI
|
return filterOff && adapter.mode != SelectableAdapter.Mode.MULTI
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -758,7 +757,7 @@ class LibraryController(
|
|||||||
if (presenter.mangaIsInCategory(item.manga, newHeader?.category?.id)) {
|
if (presenter.mangaIsInCategory(item.manga, newHeader?.category?.id)) {
|
||||||
adapter.moveItem(position, lastItemPosition!!)
|
adapter.moveItem(position, lastItemPosition!!)
|
||||||
snack = view?.snack(R.string.already_in_category) {
|
snack = view?.snack(R.string.already_in_category) {
|
||||||
anchorView = bottom_sheet
|
anchorView = filter_bottom_sheet
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -781,7 +780,7 @@ class LibraryController(
|
|||||||
snack = view?.snack(
|
snack = view?.snack(
|
||||||
resources!!.getString(R.string.moved_to_, category.name)
|
resources!!.getString(R.string.moved_to_, category.name)
|
||||||
) {
|
) {
|
||||||
anchorView = bottom_sheet
|
anchorView = filter_bottom_sheet
|
||||||
setAction(R.string.undo) {
|
setAction(R.string.undo) {
|
||||||
manga.category = category.id!!
|
manga.category = category.id!!
|
||||||
presenter.moveMangaToCategory(manga, oldCatId, mangaIds)
|
presenter.moveMangaToCategory(manga, oldCatId, mangaIds)
|
||||||
@ -802,7 +801,7 @@ class LibraryController(
|
|||||||
}, category.name
|
}, category.name
|
||||||
), Snackbar.LENGTH_LONG
|
), Snackbar.LENGTH_LONG
|
||||||
) {
|
) {
|
||||||
anchorView = bottom_sheet
|
anchorView = filter_bottom_sheet
|
||||||
}
|
}
|
||||||
if (!inQueue) LibraryUpdateService.start(view!!.context, category)
|
if (!inQueue) LibraryUpdateService.start(view!!.context, category)
|
||||||
return true
|
return true
|
||||||
@ -838,27 +837,28 @@ class LibraryController(
|
|||||||
|
|
||||||
override fun showSheet() {
|
override fun showSheet() {
|
||||||
when {
|
when {
|
||||||
bottom_sheet.sheetBehavior?.state == BottomSheetBehavior.STATE_HIDDEN -> bottom_sheet.sheetBehavior?.state =
|
filter_bottom_sheet.sheetBehavior?.state == BottomSheetBehavior.STATE_HIDDEN -> filter_bottom_sheet.sheetBehavior?.state =
|
||||||
BottomSheetBehavior.STATE_COLLAPSED
|
BottomSheetBehavior.STATE_COLLAPSED
|
||||||
bottom_sheet.sheetBehavior?.state != BottomSheetBehavior.STATE_EXPANDED -> bottom_sheet.sheetBehavior?.state = BottomSheetBehavior.STATE_EXPANDED
|
filter_bottom_sheet.sheetBehavior?.state != BottomSheetBehavior.STATE_EXPANDED -> filter_bottom_sheet.sheetBehavior?.state = BottomSheetBehavior.STATE_EXPANDED
|
||||||
else -> DisplayBottomSheet(this).show()
|
else -> DisplayBottomSheet(this).show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun toggleSheet() {
|
override fun toggleSheet() {
|
||||||
|
closeTip()
|
||||||
when {
|
when {
|
||||||
bottom_sheet.sheetBehavior?.state == BottomSheetBehavior.STATE_HIDDEN -> bottom_sheet.sheetBehavior?.state =
|
filter_bottom_sheet.sheetBehavior?.state == BottomSheetBehavior.STATE_HIDDEN -> filter_bottom_sheet.sheetBehavior?.state =
|
||||||
BottomSheetBehavior.STATE_COLLAPSED
|
BottomSheetBehavior.STATE_COLLAPSED
|
||||||
bottom_sheet.sheetBehavior?.state != BottomSheetBehavior.STATE_EXPANDED -> bottom_sheet.sheetBehavior?.state =
|
filter_bottom_sheet.sheetBehavior?.state != BottomSheetBehavior.STATE_EXPANDED -> filter_bottom_sheet.sheetBehavior?.state =
|
||||||
BottomSheetBehavior.STATE_EXPANDED
|
BottomSheetBehavior.STATE_EXPANDED
|
||||||
bottom_sheet.sheetBehavior?.isHideable == true -> bottom_sheet.sheetBehavior?.state =
|
filter_bottom_sheet.sheetBehavior?.isHideable == true -> filter_bottom_sheet.sheetBehavior?.state =
|
||||||
BottomSheetBehavior.STATE_HIDDEN
|
BottomSheetBehavior.STATE_HIDDEN
|
||||||
else -> bottom_sheet.sheetBehavior?.state = BottomSheetBehavior.STATE_COLLAPSED
|
else -> filter_bottom_sheet.sheetBehavior?.state = BottomSheetBehavior.STATE_COLLAPSED
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun handleSheetBack(): Boolean {
|
override fun handleSheetBack(): Boolean {
|
||||||
val sheetBehavior = BottomSheetBehavior.from(bottom_sheet)
|
val sheetBehavior = BottomSheetBehavior.from(filter_bottom_sheet)
|
||||||
if (sheetBehavior.state != BottomSheetBehavior.STATE_COLLAPSED && sheetBehavior.state != BottomSheetBehavior.STATE_HIDDEN) {
|
if (sheetBehavior.state != BottomSheetBehavior.STATE_COLLAPSED && sheetBehavior.state != BottomSheetBehavior.STATE_HIDDEN) {
|
||||||
sheetBehavior.state = BottomSheetBehavior.STATE_COLLAPSED
|
sheetBehavior.state = BottomSheetBehavior.STATE_COLLAPSED
|
||||||
return true
|
return true
|
||||||
@ -888,7 +888,6 @@ class LibraryController(
|
|||||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
when (item.itemId) {
|
when (item.itemId) {
|
||||||
R.id.action_search -> expandActionViewFromInteraction = true
|
R.id.action_search -> expandActionViewFromInteraction = true
|
||||||
R.id.action_library_display -> DisplayBottomSheet(this).show()
|
|
||||||
else -> return super.onOptionsItemSelected(item)
|
else -> return super.onOptionsItemSelected(item)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
@ -965,7 +964,7 @@ class LibraryController(
|
|||||||
snack = view?.snack(
|
snack = view?.snack(
|
||||||
activity?.getString(R.string.removed_from_library) ?: "", Snackbar.LENGTH_INDEFINITE
|
activity?.getString(R.string.removed_from_library) ?: "", Snackbar.LENGTH_INDEFINITE
|
||||||
) {
|
) {
|
||||||
anchorView = bottom_sheet
|
anchorView = filter_bottom_sheet
|
||||||
var undoing = false
|
var undoing = false
|
||||||
setAction(R.string.undo) {
|
setAction(R.string.undo) {
|
||||||
presenter.reAddMangas(mangas)
|
presenter.reAddMangas(mangas)
|
||||||
|
@ -37,6 +37,7 @@ import eu.kanade.tachiyomi.R
|
|||||||
import eu.kanade.tachiyomi.data.download.DownloadManager
|
import eu.kanade.tachiyomi.data.download.DownloadManager
|
||||||
import eu.kanade.tachiyomi.data.download.DownloadService
|
import eu.kanade.tachiyomi.data.download.DownloadService
|
||||||
import eu.kanade.tachiyomi.data.download.DownloadServiceListener
|
import eu.kanade.tachiyomi.data.download.DownloadServiceListener
|
||||||
|
import eu.kanade.tachiyomi.data.library.LibraryUpdateService
|
||||||
import eu.kanade.tachiyomi.data.notification.NotificationReceiver
|
import eu.kanade.tachiyomi.data.notification.NotificationReceiver
|
||||||
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
|
||||||
@ -59,6 +60,8 @@ import eu.kanade.tachiyomi.util.system.hasSideNavBar
|
|||||||
import eu.kanade.tachiyomi.util.system.isBottomTappable
|
import eu.kanade.tachiyomi.util.system.isBottomTappable
|
||||||
import eu.kanade.tachiyomi.util.system.launchUI
|
import eu.kanade.tachiyomi.util.system.launchUI
|
||||||
import eu.kanade.tachiyomi.util.view.doOnApplyWindowInsets
|
import eu.kanade.tachiyomi.util.view.doOnApplyWindowInsets
|
||||||
|
import eu.kanade.tachiyomi.util.view.getItemView
|
||||||
|
import eu.kanade.tachiyomi.util.view.snack
|
||||||
import eu.kanade.tachiyomi.util.view.updateLayoutParams
|
import eu.kanade.tachiyomi.util.view.updateLayoutParams
|
||||||
import eu.kanade.tachiyomi.util.view.updatePadding
|
import eu.kanade.tachiyomi.util.view.updatePadding
|
||||||
import eu.kanade.tachiyomi.util.view.withFadeTransaction
|
import eu.kanade.tachiyomi.util.view.withFadeTransaction
|
||||||
@ -137,6 +140,26 @@ open class MainActivity : BaseActivity(), DownloadServiceListener {
|
|||||||
)
|
)
|
||||||
|
|
||||||
var continueSwitchingTabs = false
|
var continueSwitchingTabs = false
|
||||||
|
bottom_nav.getItemView(R.id.nav_library)?.setOnLongClickListener {
|
||||||
|
if (!LibraryUpdateService.isRunning()) {
|
||||||
|
LibraryUpdateService.start(this)
|
||||||
|
main_content.snack(R.string.updating_library) {
|
||||||
|
anchorView = bottom_nav
|
||||||
|
}
|
||||||
|
}
|
||||||
|
true
|
||||||
|
}
|
||||||
|
for (id in listOf(R.id.nav_recents, R.id.nav_browse)) {
|
||||||
|
bottom_nav.getItemView(id)?.setOnLongClickListener {
|
||||||
|
bottom_nav.selectedItemId = id
|
||||||
|
bottom_nav.post {
|
||||||
|
val controller =
|
||||||
|
router.backstack.firstOrNull()?.controller() as? BottomSheetController
|
||||||
|
controller?.toggleSheet()
|
||||||
|
}
|
||||||
|
true
|
||||||
|
}
|
||||||
|
}
|
||||||
bottom_nav.setOnNavigationItemSelectedListener { item ->
|
bottom_nav.setOnNavigationItemSelectedListener { item ->
|
||||||
val id = item.itemId
|
val id = item.itemId
|
||||||
val currentController = router.backstack.lastOrNull()?.controller()
|
val currentController = router.backstack.lastOrNull()?.controller()
|
||||||
|
@ -432,8 +432,7 @@ class RecentsController(bundle: Bundle? = null) : BaseController(bundle),
|
|||||||
|
|
||||||
override fun toggleSheet() {
|
override fun toggleSheet() {
|
||||||
if (showingDownloads) dl_bottom_sheet.dismiss()
|
if (showingDownloads) dl_bottom_sheet.dismiss()
|
||||||
else if (dl_bottom_sheet.sheetBehavior?.isHideable == false) dl_bottom_sheet.sheetBehavior?.state =
|
else dl_bottom_sheet.sheetBehavior?.state = BottomSheetBehavior.STATE_EXPANDED
|
||||||
BottomSheetBehavior.STATE_EXPANDED
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun expandSearch() {
|
override fun expandSearch() {
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
package eu.kanade.tachiyomi.util.view
|
package eu.kanade.tachiyomi.util.view
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.content.res.ColorStateList
|
import android.content.res.ColorStateList
|
||||||
import android.content.res.Configuration
|
import android.content.res.Configuration
|
||||||
@ -17,11 +18,16 @@ import android.widget.Button
|
|||||||
import android.widget.FrameLayout
|
import android.widget.FrameLayout
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
|
import androidx.annotation.IdRes
|
||||||
import androidx.annotation.Px
|
import androidx.annotation.Px
|
||||||
|
import androidx.appcompat.view.menu.MenuBuilder
|
||||||
import androidx.core.graphics.ColorUtils
|
import androidx.core.graphics.ColorUtils
|
||||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||||
import com.amulyakhare.textdrawable.TextDrawable
|
import com.amulyakhare.textdrawable.TextDrawable
|
||||||
import com.amulyakhare.textdrawable.util.ColorGenerator
|
import com.amulyakhare.textdrawable.util.ColorGenerator
|
||||||
|
import com.google.android.material.bottomnavigation.BottomNavigationItemView
|
||||||
|
import com.google.android.material.bottomnavigation.BottomNavigationMenuView
|
||||||
|
import com.google.android.material.bottomnavigation.BottomNavigationView
|
||||||
import com.google.android.material.bottomsheet.BottomSheetDialog
|
import com.google.android.material.bottomsheet.BottomSheetDialog
|
||||||
import com.google.android.material.button.MaterialButton
|
import com.google.android.material.button.MaterialButton
|
||||||
import com.google.android.material.snackbar.Snackbar
|
import com.google.android.material.snackbar.Snackbar
|
||||||
@ -323,3 +329,9 @@ fun MaterialButton.resetStrokeColor() {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("RestrictedApi")
|
||||||
|
fun BottomNavigationView.getItemView(@IdRes id: Int): BottomNavigationItemView? {
|
||||||
|
val order = (menu as MenuBuilder).findItemIndex(id)
|
||||||
|
return (getChildAt(0) as BottomNavigationMenuView).getChildAt(order) as? BottomNavigationItemView
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user