From 1f8c5b0120177ecd160110026ab2e018e20dd0c1 Mon Sep 17 00:00:00 2001 From: arkon Date: Fri, 16 Apr 2021 22:26:41 -0400 Subject: [PATCH] Adjust ActionToolbar positioning --- .../tachiyomi/ui/library/LibraryController.kt | 6 ---- .../kanade/tachiyomi/ui/main/MainActivity.kt | 3 +- .../tachiyomi/ui/manga/MangaController.kt | 5 ---- .../ui/recent/updates/UpdatesController.kt | 5 ---- .../kanade/tachiyomi/widget/ActionToolbar.kt | 28 ++++++++----------- ..._action_toolbar.xml => action_toolbar.xml} | 4 +-- 6 files changed, 15 insertions(+), 36 deletions(-) rename app/src/main/res/layout/{common_action_toolbar.xml => action_toolbar.xml} (92%) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt index d6f73899eb..f9ada2c8c3 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt @@ -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 } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt index b4282ec5e4..eaa367698d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt @@ -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() { 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 diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaController.kt index 2ad2fd170c..347b5adf44 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaController.kt @@ -206,11 +206,6 @@ class MangaController : padding() } } - binding.actionToolbar.applyInsetter { - type(navigationBars = true) { - margin(bottom = true) - } - } return binding.root } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesController.kt index 4dca1f14ac..3f1f3e5773 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesController.kt @@ -78,11 +78,6 @@ class UpdatesController : padding() } } - binding.actionToolbar.applyInsetter { - type(navigationBars = true) { - margin(bottom = true) - } - } return binding.root } diff --git a/app/src/main/java/eu/kanade/tachiyomi/widget/ActionToolbar.kt b/app/src/main/java/eu/kanade/tachiyomi/widget/ActionToolbar.kt index b00ed4ed35..2260cd7bd9 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/widget/ActionToolbar.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/widget/ActionToolbar.kt @@ -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) } } diff --git a/app/src/main/res/layout/common_action_toolbar.xml b/app/src/main/res/layout/action_toolbar.xml similarity index 92% rename from app/src/main/res/layout/common_action_toolbar.xml rename to app/src/main/res/layout/action_toolbar.xml index dc4c123052..43835cebfe 100644 --- a/app/src/main/res/layout/common_action_toolbar.xml +++ b/app/src/main/res/layout/action_toolbar.xml @@ -2,7 +2,7 @@