From 2e195d154f9d4b49a4118123674c85848523b2f2 Mon Sep 17 00:00:00 2001 From: kunfei Date: Wed, 28 Sep 2022 20:26:58 +0800 Subject: [PATCH] =?UTF-8?q?=E9=98=85=E8=AF=BB=E7=95=8C=E9=9D=A2=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E4=B9=A6=E6=BA=90=E5=90=8D=E7=A7=B0,=E7=99=BB?= =?UTF-8?q?=E9=99=86=E5=92=8C=E8=B4=AD=E4=B9=B0=E7=A7=BB=E5=88=B0=E4=B9=A6?= =?UTF-8?q?=E6=BA=90=E8=8F=9C=E5=8D=95=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/ui/book/read/ReadMenu.kt | 22 +++++------ app/src/main/res/layout/view_read_menu.xml | 38 ++----------------- app/src/main/res/menu/book_read_source.xml | 10 +++++ 3 files changed, 24 insertions(+), 46 deletions(-) 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 1260b0eed..b79722647 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 @@ -84,6 +84,8 @@ class ReadMenu @JvmOverloads constructor( inflate(R.menu.book_read_source) setOnMenuItemClickListener { when (it.itemId) { + R.id.menu_login -> callBack.showLogin() + R.id.menu_chapter_pay -> callBack.payAction() R.id.menu_edit_source -> callBack.openSourceEditActivity() R.id.menu_disable_source -> callBack.disableSource() } @@ -93,11 +95,9 @@ class ReadMenu @JvmOverloads constructor( } private val menuInListener = object : Animation.AnimationListener { override fun onAnimationStart(animation: Animation) { + binding.tvSourceAction.text = + ReadBook.bookSource?.bookSourceName ?: context.getString(R.string.book_source) binding.tvSourceAction.isGone = ReadBook.isLocalBook - binding.tvLogin.isGone = ReadBook.bookSource?.loginUrl.isNullOrEmpty() - binding.tvPay.isGone = ReadBook.bookSource?.loginUrl.isNullOrEmpty() - || ReadBook.curTextChapter?.isVip != true - || ReadBook.curTextChapter?.isPay == true callBack.upSystemUiVisibility() binding.llBrightness.visible(showBrightnessView) } @@ -335,16 +335,14 @@ class ReadMenu @JvmOverloads constructor( tvChapterName.setOnLongClickListener(chapterViewLongClickListener) tvChapterUrl.setOnClickListener(chapterViewClickListener) tvChapterUrl.setOnLongClickListener(chapterViewLongClickListener) - //登录 - tvLogin.setOnClickListener { - callBack.showLogin() - } - //购买 - tvPay.setOnClickListener { - callBack.payAction() - } //书源操作 tvSourceAction.onClick { + sourceMenu.menu.findItem(R.id.menu_login).isVisible = + !ReadBook.bookSource?.loginUrl.isNullOrEmpty() + sourceMenu.menu.findItem(R.id.menu_chapter_pay).isVisible = + !ReadBook.bookSource?.loginUrl.isNullOrEmpty() + && ReadBook.curTextChapter?.isVip == true + && ReadBook.curTextChapter?.isPay != true sourceMenu.show() } //亮度跟随 diff --git a/app/src/main/res/layout/view_read_menu.xml b/app/src/main/res/layout/view_read_menu.xml index ca8160cad..94a365804 100644 --- a/app/src/main/res/layout/view_read_menu.xml +++ b/app/src/main/res/layout/view_read_menu.xml @@ -35,7 +35,7 @@ android:singleLine="true" android:visibility="gone" app:layout_constraintLeft_toLeftOf="parent" - app:layout_constraintRight_toLeftOf="@+id/tv_login" + app:layout_constraintRight_toLeftOf="@+id/tv_source_action" app:layout_constraintTop_toTopOf="parent" /> - - - - + app:radius="2dp" /> diff --git a/app/src/main/res/menu/book_read_source.xml b/app/src/main/res/menu/book_read_source.xml index a83f99b00..776e6038a 100644 --- a/app/src/main/res/menu/book_read_source.xml +++ b/app/src/main/res/menu/book_read_source.xml @@ -4,6 +4,16 @@ tools:context=".ui.main.MainActivity" tools:ignore="AlwaysShowAction"> + + + +