From d35300798832fdde96be984d963470e279e2ba47 Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 3 Feb 2020 11:42:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/book/read/ReadBookActivity.kt | 21 +++++++++++++++++-- .../ui/book/read/config/ReadAloudDialog.kt | 4 ++-- 2 files changed, 21 insertions(+), 4 deletions(-) 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 f11f3c835..ee387edb8 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 @@ -67,6 +67,7 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo private val requestCodeChapterList = 568 private val requestCodeEditSource = 111 private val requestCodeReplace = 312 + private var replaceUseMenu: MenuItem? = null override val viewModel: ReadBookViewModel get() = getViewModel(ReadBookViewModel::class.java) @@ -85,7 +86,10 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo initView() upScreenTimeOut() ReadBook.callBack = this - ReadBook.titleDate.observe(this, Observer { title_bar.title = it }) + ReadBook.titleDate.observe(this, Observer { + title_bar.title = it + upMenu() + }) viewModel.initData(intent) } @@ -143,9 +147,18 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo override fun onCompatCreateOptionsMenu(menu: Menu): Boolean { menuInflater.inflate(R.menu.read_book, menu) + replaceUseMenu = menu.findItem(R.id.menu_enable_replace) + upMenu() return super.onCompatCreateOptionsMenu(menu) } + private fun upMenu() { + ReadBook.book?.let { + replaceUseMenu?.isChecked = it.useReplaceRule + } + + } + /** * 菜单 */ @@ -222,6 +235,10 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo R.id.menu_update_toc -> ReadBook.book?.let { viewModel.loadChapterList(it) } + R.id.menu_enable_replace -> ReadBook.book?.let { + it.useReplaceRule = !it.useReplaceRule + replaceUseMenu?.isChecked = it.useReplaceRule + } } return super.onCompatOptionsItemSelected(item) } @@ -378,7 +395,7 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo seek_read_page.progress = ReadBook.durPageIndex } - override fun showMenu() { + override fun showMenuBar() { read_menu.runMenuIn() } 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 a20ac2efe..f464d99b2 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 @@ -101,7 +101,7 @@ class ReadAloudDialog : DialogFragment() { } private fun initOnClick() { - iv_menu.onClick { callBack?.showMenu(); dismiss() } + iv_menu.onClick { callBack?.showMenuBar(); dismiss() } iv_other_config.onClick { ReadAloudConfigDialog().show(childFragmentManager, "readAloudConfigDialog") } @@ -135,7 +135,7 @@ class ReadAloudDialog : DialogFragment() { } interface CallBack { - fun showMenu() + fun showMenuBar() fun openChapterList() fun onClickReadAloud() fun finish()