mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-19 03:09:19 +01:00
Less hacky way to make sure bottom action toolbar doesn't scroll down (#5871)
* Less hacky way to make sure bottom action toolbar doesn't scroll down * Fix action toolbar overlapping on landscape * Disable app bar transparency when ActionMode is present
This commit is contained in:
parent
52daf3d58c
commit
7b3c18bb97
@ -169,7 +169,7 @@ class LibraryController(
|
|||||||
|
|
||||||
binding.actionToolbar.applyInsetter {
|
binding.actionToolbar.applyInsetter {
|
||||||
type(navigationBars = true) {
|
type(navigationBars = true) {
|
||||||
margin(bottom = true)
|
margin(bottom = true, horizontal = true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -216,8 +216,6 @@ class LibraryController(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
.launchIn(viewScope)
|
.launchIn(viewScope)
|
||||||
|
|
||||||
(activity as? MainActivity)?.fixViewToBottom(binding.actionToolbar)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onChangeStarted(handler: ControllerChangeHandler, type: ControllerChangeType) {
|
override fun onChangeStarted(handler: ControllerChangeHandler, type: ControllerChangeType) {
|
||||||
@ -230,7 +228,6 @@ class LibraryController(
|
|||||||
|
|
||||||
override fun onDestroyView(view: View) {
|
override fun onDestroyView(view: View) {
|
||||||
destroyActionModeIfNeeded()
|
destroyActionModeIfNeeded()
|
||||||
(activity as? MainActivity)?.clearFixViewToBottom(binding.actionToolbar)
|
|
||||||
binding.actionToolbar.destroy()
|
binding.actionToolbar.destroy()
|
||||||
adapter?.onDestroy()
|
adapter?.onDestroy()
|
||||||
adapter = null
|
adapter = null
|
||||||
|
@ -7,9 +7,9 @@ import android.graphics.Color
|
|||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.Gravity
|
import android.view.Gravity
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
|
import androidx.appcompat.view.ActionMode
|
||||||
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||||
import androidx.core.animation.doOnEnd
|
import androidx.core.animation.doOnEnd
|
||||||
import androidx.core.splashscreen.SplashScreen
|
import androidx.core.splashscreen.SplashScreen
|
||||||
@ -91,8 +91,6 @@ class MainActivity : BaseViewBindingActivity<MainActivityBinding>() {
|
|||||||
private var isConfirmingExit: Boolean = false
|
private var isConfirmingExit: Boolean = false
|
||||||
private var isHandlingShortcut: Boolean = false
|
private var isHandlingShortcut: Boolean = false
|
||||||
|
|
||||||
private var fixedViewsToBottom = mutableMapOf<View, AppBarLayout.OnOffsetChangedListener>()
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* App bar lift state for backstack
|
* App bar lift state for backstack
|
||||||
*/
|
*/
|
||||||
@ -477,6 +475,24 @@ class MainActivity : BaseViewBindingActivity<MainActivityBinding>() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onSupportActionModeStarted(mode: ActionMode) {
|
||||||
|
binding.appbar.apply {
|
||||||
|
tag = isTransparentWhenNotLifted
|
||||||
|
isTransparentWhenNotLifted = false
|
||||||
|
}
|
||||||
|
setToolbarScrolls(false)
|
||||||
|
super.onSupportActionModeStarted(mode)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onSupportActionModeFinished(mode: ActionMode) {
|
||||||
|
binding.appbar.apply {
|
||||||
|
isTransparentWhenNotLifted = (tag as? Boolean) ?: false
|
||||||
|
tag = null
|
||||||
|
}
|
||||||
|
setToolbarScrolls(true)
|
||||||
|
super.onSupportActionModeFinished(mode)
|
||||||
|
}
|
||||||
|
|
||||||
private suspend fun resetExitConfirmation() {
|
private suspend fun resetExitConfirmation() {
|
||||||
isConfirmingExit = true
|
isConfirmingExit = true
|
||||||
val toast = toast(R.string.confirm_exit, Toast.LENGTH_LONG)
|
val toast = toast(R.string.confirm_exit, Toast.LENGTH_LONG)
|
||||||
@ -595,21 +611,15 @@ class MainActivity : BaseViewBindingActivity<MainActivityBinding>() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to manually offset a view within the activity's child views that might be cut off due to
|
* Sets toolbar CoordinatorLayout scroll flags
|
||||||
* the collapsing AppBarLayout.
|
|
||||||
*/
|
*/
|
||||||
fun fixViewToBottom(view: View) {
|
private fun setToolbarScrolls(enabled: Boolean) = binding.toolbar.updateLayoutParams<AppBarLayout.LayoutParams> {
|
||||||
val listener = AppBarLayout.OnOffsetChangedListener { appBarLayout, verticalOffset ->
|
if (isTablet()) return@updateLayoutParams
|
||||||
val maxAbsOffset = appBarLayout.measuredHeight - binding.tabs.measuredHeight
|
scrollFlags = if (enabled) {
|
||||||
view.translationY = -maxAbsOffset - verticalOffset.toFloat() + appBarLayout.paddingTop
|
AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL or AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS
|
||||||
|
} else {
|
||||||
|
0
|
||||||
}
|
}
|
||||||
binding.appbar.addOnOffsetChangedListener(listener)
|
|
||||||
fixedViewsToBottom[view] = listener
|
|
||||||
}
|
|
||||||
|
|
||||||
fun clearFixViewToBottom(view: View) {
|
|
||||||
val listener = fixedViewsToBottom.remove(view)
|
|
||||||
binding.appbar.removeOnOffsetChangedListener(listener)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setBottomNavBehaviorOnScroll() {
|
private fun setBottomNavBehaviorOnScroll() {
|
||||||
|
@ -235,7 +235,7 @@ class MangaController :
|
|||||||
}
|
}
|
||||||
binding.actionToolbar.applyInsetter {
|
binding.actionToolbar.applyInsetter {
|
||||||
type(navigationBars = true) {
|
type(navigationBars = true) {
|
||||||
margin(bottom = true)
|
margin(bottom = true, horizontal = true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -329,8 +329,6 @@ class MangaController :
|
|||||||
}
|
}
|
||||||
.launchIn(viewScope)
|
.launchIn(viewScope)
|
||||||
|
|
||||||
(activity as? MainActivity)?.fixViewToBottom(binding.actionToolbar)
|
|
||||||
|
|
||||||
settingsSheet = ChaptersSettingsSheet(router, presenter) { group ->
|
settingsSheet = ChaptersSettingsSheet(router, presenter) { group ->
|
||||||
if (group is ChaptersSettingsSheet.Filter.FilterGroup) {
|
if (group is ChaptersSettingsSheet.Filter.FilterGroup) {
|
||||||
updateFilterIconState()
|
updateFilterIconState()
|
||||||
@ -402,7 +400,6 @@ class MangaController :
|
|||||||
|
|
||||||
override fun onDestroyView(view: View) {
|
override fun onDestroyView(view: View) {
|
||||||
destroyActionModeIfNeeded()
|
destroyActionModeIfNeeded()
|
||||||
(activity as? MainActivity)?.clearFixViewToBottom(binding.actionToolbar)
|
|
||||||
binding.actionToolbar.destroy()
|
binding.actionToolbar.destroy()
|
||||||
mangaInfoAdapter = null
|
mangaInfoAdapter = null
|
||||||
chaptersHeaderAdapter = null
|
chaptersHeaderAdapter = null
|
||||||
|
@ -82,7 +82,7 @@ class UpdatesController :
|
|||||||
}
|
}
|
||||||
binding.actionToolbar.applyInsetter {
|
binding.actionToolbar.applyInsetter {
|
||||||
type(navigationBars = true) {
|
type(navigationBars = true) {
|
||||||
margin(bottom = true)
|
margin(bottom = true, horizontal = true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,13 +113,10 @@ class UpdatesController :
|
|||||||
binding.swipeRefresh.isRefreshing = false
|
binding.swipeRefresh.isRefreshing = false
|
||||||
}
|
}
|
||||||
.launchIn(viewScope)
|
.launchIn(viewScope)
|
||||||
|
|
||||||
(activity as? MainActivity)?.fixViewToBottom(binding.actionToolbar)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroyView(view: View) {
|
override fun onDestroyView(view: View) {
|
||||||
destroyActionModeIfNeeded()
|
destroyActionModeIfNeeded()
|
||||||
(activity as? MainActivity)?.clearFixViewToBottom(binding.actionToolbar)
|
|
||||||
binding.actionToolbar.destroy()
|
binding.actionToolbar.destroy()
|
||||||
adapter = null
|
adapter = null
|
||||||
super.onDestroyView(view)
|
super.onDestroyView(view)
|
||||||
|
Loading…
Reference in New Issue
Block a user