From f32b336ff8131fd441f3c769f29da6dec14a1352 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sun, 15 Aug 2021 23:22:39 +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 --- .../io/legado/app/ui/book/read/ReadBookActivity.kt | 13 +++++++------ .../legado/app/ui/book/read/ReadBookBaseActivity.kt | 9 +-------- 2 files changed, 8 insertions(+), 14 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 0e0152540..f2142fbdd 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 @@ -45,6 +45,7 @@ import io.legado.app.ui.book.read.page.entities.PageDirection import io.legado.app.ui.book.read.page.provider.TextPageFactory import io.legado.app.ui.book.searchContent.SearchContentActivity import io.legado.app.ui.book.source.edit.BookSourceEditActivity +import io.legado.app.ui.book.toc.BookmarkDialog import io.legado.app.ui.book.toc.TocActivityResult import io.legado.app.ui.dict.DictDialog import io.legado.app.ui.login.SourceLoginActivity @@ -110,7 +111,7 @@ class ReadBookActivity : ReadBookBaseActivity(), override val isInitFinish: Boolean get() = viewModel.isInitFinish override val isScroll: Boolean get() = binding.readView.isScroll private val mHandler = Handler(Looper.getMainLooper()) - private val keepScreenRunnable = Runnable { keepScreenOn(window, false) } + private val keepScreenRunnable = Runnable { keepScreenOn(false) } private val autoPageRunnable = Runnable { autoPagePlus() } private val backupRunnable = Runnable { if (!BuildConfig.DEBUG) { @@ -251,7 +252,7 @@ class ReadBookActivity : ReadBookBaseActivity(), chapterName = page.title bookText = page.text.trim() } - showBookMark(bookmark) + BookmarkDialog.start(supportFragmentManager, bookmark) } } R.id.menu_copy_text -> @@ -513,7 +514,7 @@ class ReadBookActivity : ReadBookBaseActivity(), if (bookmark == null) { toastOnUi(R.string.create_bookmark_error) } else { - showBookMark(bookmark) + BookmarkDialog.start(supportFragmentManager, bookmark) } return true } @@ -983,16 +984,16 @@ class ReadBookActivity : ReadBookBaseActivity(), */ override fun screenOffTimerStart() { if (screenTimeOut < 0) { - keepScreenOn(window, true) + keepScreenOn(true) return } val t = screenTimeOut - sysScreenOffTime if (t > 0) { mHandler.removeCallbacks(keepScreenRunnable) - keepScreenOn(window, true) + keepScreenOn(true) mHandler.postDelayed(keepScreenRunnable, screenTimeOut) } else { - keepScreenOn(window, false) + keepScreenOn(false) } } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookBaseActivity.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookBaseActivity.kt index 120a494f1..e057b6419 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookBaseActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookBaseActivity.kt @@ -12,7 +12,6 @@ import io.legado.app.R import io.legado.app.base.VMBaseActivity import io.legado.app.constant.AppConst.charsets import io.legado.app.constant.PreferKey -import io.legado.app.data.entities.Bookmark import io.legado.app.databinding.ActivityBookReadBinding import io.legado.app.databinding.DialogDownloadChoiceBinding import io.legado.app.databinding.DialogEditTextBinding @@ -29,7 +28,6 @@ import io.legado.app.service.help.ReadBook import io.legado.app.ui.book.read.config.BgTextConfigDialog import io.legado.app.ui.book.read.config.ClickActionConfigDialog import io.legado.app.ui.book.read.config.PaddingConfigDialog -import io.legado.app.ui.book.toc.BookmarkDialog import io.legado.app.utils.getPrefString import io.legado.app.utils.viewbindingdelegate.viewBinding @@ -152,7 +150,7 @@ abstract class ReadBookBaseActivity : /** * 保持亮屏 */ - fun keepScreenOn(window: Window, on: Boolean) { + fun keepScreenOn(on: Boolean) { if (on) { window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) } else { @@ -194,11 +192,6 @@ abstract class ReadBookBaseActivity : } } - @SuppressLint("InflateParams") - fun showBookMark(bookmark: Bookmark) { - BookmarkDialog.start(supportFragmentManager, bookmark) - } - fun showCharsetConfig() { alert(R.string.set_charset) { val alertBinding = DialogEditTextBinding.inflate(layoutInflater).apply {