Adjust ActionToolbar positioning
This commit is contained in:
parent
c7f839ea4a
commit
1f8c5b0120
@ -18,7 +18,6 @@ import com.google.android.material.tabs.TabLayout
|
||||
import com.jakewharton.rxrelay.BehaviorRelay
|
||||
import com.jakewharton.rxrelay.PublishRelay
|
||||
import com.tfcporciuncula.flow.Preference
|
||||
import dev.chrisbanes.insetter.applyInsetter
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.database.models.Category
|
||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||
@ -166,11 +165,6 @@ class LibraryController(
|
||||
|
||||
override fun inflateView(inflater: LayoutInflater, container: ViewGroup): View {
|
||||
binding = LibraryControllerBinding.inflate(inflater)
|
||||
binding.actionToolbar.applyInsetter {
|
||||
type(navigationBars = true) {
|
||||
margin(bottom = true)
|
||||
}
|
||||
}
|
||||
return binding.root
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,6 @@ import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.WindowCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.core.view.marginTop
|
||||
import androidx.core.view.updateLayoutParams
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.preference.PreferenceDialogController
|
||||
@ -446,7 +445,7 @@ class MainActivity : BaseViewBindingActivity<MainActivityBinding>() {
|
||||
fun fixViewToBottom(view: View) {
|
||||
val listener = AppBarLayout.OnOffsetChangedListener { appBarLayout, verticalOffset ->
|
||||
val maxAbsOffset = appBarLayout.measuredHeight - binding.tabs.measuredHeight
|
||||
view.translationY = -maxAbsOffset - verticalOffset.toFloat() - appBarLayout.marginTop
|
||||
view.translationY = -maxAbsOffset - verticalOffset.toFloat()
|
||||
}
|
||||
binding.appbar.addOnOffsetChangedListener(listener)
|
||||
fixedViewsToBottom[view] = listener
|
||||
|
@ -206,11 +206,6 @@ class MangaController :
|
||||
padding()
|
||||
}
|
||||
}
|
||||
binding.actionToolbar.applyInsetter {
|
||||
type(navigationBars = true) {
|
||||
margin(bottom = true)
|
||||
}
|
||||
}
|
||||
return binding.root
|
||||
}
|
||||
|
||||
|
@ -78,11 +78,6 @@ class UpdatesController :
|
||||
padding()
|
||||
}
|
||||
}
|
||||
binding.actionToolbar.applyInsetter {
|
||||
type(navigationBars = true) {
|
||||
margin(bottom = true)
|
||||
}
|
||||
}
|
||||
return binding.root
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ import androidx.annotation.MenuRes
|
||||
import androidx.appcompat.view.ActionMode
|
||||
import androidx.core.view.isVisible
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.databinding.CommonActionToolbarBinding
|
||||
import eu.kanade.tachiyomi.databinding.ActionToolbarBinding
|
||||
|
||||
/**
|
||||
* A toolbar holding only menu items.
|
||||
@ -20,25 +20,21 @@ import eu.kanade.tachiyomi.databinding.CommonActionToolbarBinding
|
||||
class ActionToolbar @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
|
||||
FrameLayout(context, attrs) {
|
||||
|
||||
private val binding: CommonActionToolbarBinding
|
||||
|
||||
init {
|
||||
binding = CommonActionToolbarBinding.inflate(LayoutInflater.from(context), this, true)
|
||||
}
|
||||
private val binding = ActionToolbarBinding.inflate(LayoutInflater.from(context), this, true)
|
||||
|
||||
/**
|
||||
* Remove menu items and remove listener.
|
||||
*/
|
||||
fun destroy() {
|
||||
binding.commonActionMenu.menu.clear()
|
||||
binding.commonActionMenu.setOnMenuItemClickListener(null)
|
||||
binding.menu.menu.clear()
|
||||
binding.menu.setOnMenuItemClickListener(null)
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a menu item if found.
|
||||
*/
|
||||
fun findItem(@IdRes itemId: Int): MenuItem? {
|
||||
return binding.commonActionMenu.menu.findItem(itemId)
|
||||
return binding.menu.menu.findItem(itemId)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -46,14 +42,14 @@ class ActionToolbar @JvmOverloads constructor(context: Context, attrs: Attribute
|
||||
*/
|
||||
fun show(mode: ActionMode, @MenuRes menuRes: Int, listener: (item: MenuItem?) -> Boolean) {
|
||||
// Avoid re-inflating the menu
|
||||
if (binding.commonActionMenu.menu.size() == 0) {
|
||||
mode.menuInflater.inflate(menuRes, binding.commonActionMenu.menu)
|
||||
binding.commonActionMenu.setOnMenuItemClickListener { listener(it) }
|
||||
if (binding.menu.menu.size() == 0) {
|
||||
mode.menuInflater.inflate(menuRes, binding.menu.menu)
|
||||
binding.menu.setOnMenuItemClickListener { listener(it) }
|
||||
}
|
||||
|
||||
binding.commonActionToolbar.isVisible = true
|
||||
binding.actionToolbar.isVisible = true
|
||||
val bottomAnimation = AnimationUtils.loadAnimation(context, R.anim.enter_from_bottom)
|
||||
binding.commonActionToolbar.startAnimation(bottomAnimation)
|
||||
binding.actionToolbar.startAnimation(bottomAnimation)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -64,10 +60,10 @@ class ActionToolbar @JvmOverloads constructor(context: Context, attrs: Attribute
|
||||
bottomAnimation.setAnimationListener(
|
||||
object : SimpleAnimationListener() {
|
||||
override fun onAnimationEnd(animation: Animation) {
|
||||
binding.commonActionToolbar.isVisible = false
|
||||
binding.actionToolbar.isVisible = false
|
||||
}
|
||||
}
|
||||
)
|
||||
binding.commonActionToolbar.startAnimation(bottomAnimation)
|
||||
binding.actionToolbar.startAnimation(bottomAnimation)
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/common_action_toolbar"
|
||||
android:id="@+id/action_toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:clipToPadding="false"
|
||||
@ -25,7 +25,7 @@
|
||||
app:contentInsetStart="8dp">
|
||||
|
||||
<androidx.appcompat.widget.ActionMenuView
|
||||
android:id="@+id/common_action_menu"
|
||||
android:id="@+id/menu"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
Loading…
Reference in New Issue
Block a user