diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt index dd75a8d5fc03..fe0932688190 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt @@ -111,7 +111,6 @@ import io.legado.app.utils.isAbsUrl import io.legado.app.utils.isTrue import io.legado.app.utils.launch import io.legado.app.utils.navigationBarGravity -import io.legado.app.utils.navigationBarHeight import io.legado.app.utils.observeEvent import io.legado.app.utils.observeEventSticky import io.legado.app.utils.postEvent @@ -297,7 +296,7 @@ class ReadBookActivity : BaseReadBookActivity(), if (!ReadBook.inBookshelf) { viewModel.removeFromBookshelf(null) } - viewModel.initData(intent ?: return) + viewModel.initData(intent) } override fun onWindowFocusChanged(hasFocus: Boolean) { @@ -776,7 +775,7 @@ class ReadBookActivity : BaseReadBookActivity(), override fun showTextActionMenu() { val navigationBarHeight = if (!ReadBookConfig.hideNavigationBar && navigationBarGravity == Gravity.BOTTOM) - navigationBarHeight else 0 + binding.navigationBar.height else 0 textActionMenu.show( binding.textMenuPosition, binding.root.height + navigationBarHeight, @@ -1341,7 +1340,7 @@ class ReadBookActivity : BaseReadBookActivity(), } val navigationBarHeight = if (!ReadBookConfig.hideNavigationBar && navigationBarGravity == Gravity.BOTTOM) - navigationBarHeight else 0 + binding.navigationBar.height else 0 popupAction.showAtLocation( binding.readView, Gravity.BOTTOM or Gravity.LEFT, x.toInt(), binding.root.height + navigationBarHeight - y.toInt() diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt index 75395062dd66..06d5a6ceb950 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt @@ -64,6 +64,7 @@ class ReadMenu @JvmOverloads constructor( private val callBack: CallBack get() = activity as CallBack private val binding = ViewReadMenuBinding.inflate(LayoutInflater.from(context), this, true) private var confirmSkipToChapter: Boolean = false + private var isMenuOutAnimating = false private val menuTopIn: Animation by lazy { loadAnimation(context, R.anim.anim_readbook_top_in) } @@ -151,6 +152,7 @@ class ReadMenu @JvmOverloads constructor( } private val menuOutListener = object : Animation.AnimationListener { override fun onAnimationStart(animation: Animation) { + isMenuOutAnimating = true binding.vwMenuBg.setOnClickListener(null) } @@ -159,6 +161,7 @@ class ReadMenu @JvmOverloads constructor( binding.titleBar.invisible() binding.bottomMenu.invisible() canShowMenu = false + isMenuOutAnimating = false onMenuOutEnd?.invoke() callBack.upSystemUiVisibility() } @@ -309,6 +312,9 @@ class ReadMenu @JvmOverloads constructor( } fun runMenuOut(anim: Boolean = !AppConfig.isEInkMode, onMenuOutEnd: (() -> Unit)? = null) { + if (isMenuOutAnimating) { + return + } callBack.onMenuHide() this.onMenuOutEnd = onMenuOutEnd if (this.isVisible) { diff --git a/app/src/main/java/io/legado/app/ui/book/read/SearchMenu.kt b/app/src/main/java/io/legado/app/ui/book/read/SearchMenu.kt index 6edf40f808f6..f957a2b4c7a1 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/SearchMenu.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/SearchMenu.kt @@ -48,6 +48,7 @@ class SearchMenu @JvmOverloads constructor( Selector.colorBuild().setDefaultColor(bgColor) .setPressedColor(ColorUtils.darkenColor(bgColor)).create() private var onMenuOutEnd: (() -> Unit)? = null + private var isMenuOutAnimating = false private val searchResultList: MutableList = mutableListOf() private var currentSearchResultIndex: Int = -1 @@ -94,18 +95,18 @@ class SearchMenu @JvmOverloads constructor( fun runMenuIn() { this.visible() - binding.llSearchBaseInfo.visible() - binding.llBottomBg.visible() + binding.llBottomMenu.visible() binding.vwMenuBg.visible() - binding.llSearchBaseInfo.startAnimation(menuBottomIn) - binding.llBottomBg.startAnimation(menuBottomIn) + binding.llBottomMenu.startAnimation(menuBottomIn) } fun runMenuOut(onMenuOutEnd: (() -> Unit)? = null) { + if (isMenuOutAnimating) { + return + } this.onMenuOutEnd = onMenuOutEnd if (this.isVisible) { - binding.llSearchBaseInfo.startAnimation(menuBottomOut) - binding.llBottomBg.startAnimation(menuBottomOut) + binding.llBottomMenu.startAnimation(menuBottomOut) } } @@ -216,12 +217,13 @@ class SearchMenu @JvmOverloads constructor( //隐藏菜单 menuBottomOut.setAnimationListener(object : Animation.AnimationListener { override fun onAnimationStart(animation: Animation) { + isMenuOutAnimating = true binding.vwMenuBg.setOnClickListener(null) } override fun onAnimationEnd(animation: Animation) { - binding.llSearchBaseInfo.invisible() - binding.llBottomBg.invisible() + isMenuOutAnimating = false + binding.llBottomMenu.invisible() binding.vwMenuBg.invisible() binding.vwMenuBg.setOnClickListener { runMenuOut() } diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/AutoReadDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/AutoReadDialog.kt index b637a9fe6744..59d02a1a1a2a 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/AutoReadDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/AutoReadDialog.kt @@ -49,7 +49,11 @@ class AutoReadDialog : BaseDialogFragment(R.layout.dialog_auto_read) { } override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) = binding.run { - (activity as ReadBookActivity).bottomDialog++ + val bottomDialog = (activity as ReadBookActivity).bottomDialog++ + if (bottomDialog > 0) { + dismiss() + return + } val bg = requireContext().bottomBackground val isLight = ColorUtils.isColorLight(bg) val textColor = requireContext().getPrimaryTextColor(isLight) diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/ReadAloudDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/ReadAloudDialog.kt index 183c3c0b291d..56928ef7736b 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/ReadAloudDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/ReadAloudDialog.kt @@ -49,7 +49,11 @@ class ReadAloudDialog : BaseDialogFragment(R.layout.dialog_read_aloud) { } override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) { - (activity as ReadBookActivity).bottomDialog++ + val bottomDialog = (activity as ReadBookActivity).bottomDialog++ + if (bottomDialog > 0) { + dismiss() + return + } val bg = requireContext().bottomBackground val isLight = ColorUtils.isColorLight(bg) val textColor = requireContext().getPrimaryTextColor(isLight) diff --git a/app/src/main/res/layout/view_search_menu.xml b/app/src/main/res/layout/view_search_menu.xml index d5d311cfbc14..624551f18838 100644 --- a/app/src/main/res/layout/view_search_menu.xml +++ b/app/src/main/res/layout/view_search_menu.xml @@ -13,7 +13,7 @@ android:contentDescription="@string/content" tools:layout_editor_absoluteX="0dp" tools:layout_editor_absoluteY="0dp" - tools:visibility="invisible"/> + tools:visibility="invisible" /> - - - - - - - - - - - - + android:id="@+id/ll_search_base_info" + android:layout_width="match_parent" + android:layout_height="36dp" + android:background="@color/background_menu" + android:gravity="center_vertical" + android:orientation="horizontal" + android:paddingLeft="10dp" + android:paddingRight="10dp"> + + tools:ignore="UnusedAttribute" /> - - - + android:baselineAligned="false" + android:orientation="horizontal"> - + android:importantForAccessibility="no" /> - - + + - - - - + + + + + + + + + + + + + + + + + + android:focusable="true" + android:orientation="vertical" + android:paddingBottom="7dp"> - - + + + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - - - - - - - + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + - + + +