pull/1251/head
gedoor 3 years ago
parent 9f5ee794d5
commit f32b336ff8
  1. 13
      app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt
  2. 9
      app/src/main/java/io/legado/app/ui/book/read/ReadBookBaseActivity.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)
}
}
}

@ -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 {

Loading…
Cancel
Save