pull/78/head
kunfei 5 years ago
parent cc6db2733a
commit bebce7d7a2
  1. 1
      app/src/main/java/io/legado/app/constant/PreferKey.kt
  2. 8
      app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt
  3. 1
      app/src/main/java/io/legado/app/ui/book/read/config/MoreConfigDialog.kt
  4. 3
      app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt

@ -20,4 +20,5 @@ object PreferKey {
const val fontFolder = "fontFolder" const val fontFolder = "fontFolder"
const val backupPath = "backupUri" const val backupPath = "backupUri"
const val threadCount = "threadCount" const val threadCount = "threadCount"
const val keepLight = "keep_light"
} }

@ -553,18 +553,22 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_boo
observeEvent<String>(Bus.REPLACE) { observeEvent<String>(Bus.REPLACE) {
ReplaceEditDialog().show(supportFragmentManager, "replaceEditDialog") ReplaceEditDialog().show(supportFragmentManager, "replaceEditDialog")
} }
observeEvent<Boolean>(PreferKey.keepLight) {
upScreenTimeOut()
}
} }
private fun upScreenTimeOut() { private fun upScreenTimeOut() {
getPrefString("keep_light")?.let { getPrefString(PreferKey.keepLight)?.let {
screenTimeOut = it.toLong() * 1000 screenTimeOut = it.toLong() * 1000
} }
screenOffTimerStart()
} }
/** /**
* 重置黑屏时间 * 重置黑屏时间
*/ */
fun screenOffTimerStart() { override fun screenOffTimerStart() {
if (screenTimeOut < 0) { if (screenTimeOut < 0) {
Help.keepScreenOn(window, true) Help.keepScreenOn(window, true)
return return

@ -95,6 +95,7 @@ class MoreConfigDialog : DialogFragment() {
PreferKey.hideStatusBar -> postEvent(Bus.UP_CONFIG, true) PreferKey.hideStatusBar -> postEvent(Bus.UP_CONFIG, true)
PreferKey.hideNavigationBar -> postEvent(Bus.UP_CONFIG, true) PreferKey.hideNavigationBar -> postEvent(Bus.UP_CONFIG, true)
PreferKey.clickAllNext -> postEvent(Bus.UP_CONFIG, true) PreferKey.clickAllNext -> postEvent(Bus.UP_CONFIG, true)
PreferKey.keepLight -> postEvent(PreferKey.keepLight, true)
} }
} }

@ -65,6 +65,7 @@ class PageView(context: Context, attrs: AttributeSet) :
@SuppressLint("ClickableViewAccessibility") @SuppressLint("ClickableViewAccessibility")
override fun onTouchEvent(event: MotionEvent): Boolean { override fun onTouchEvent(event: MotionEvent): Boolean {
callBack?.screenOffTimerStart()
return pageDelegate?.onTouch(event) ?: super.onTouchEvent(event) return pageDelegate?.onTouch(event) ?: super.onTouchEvent(event)
} }
@ -241,5 +242,7 @@ class PageView(context: Context, attrs: AttributeSet) :
fun clickCenter() fun clickCenter()
val isInitFinish: Boolean val isInitFinish: Boolean
fun screenOffTimerStart()
} }
} }

Loading…
Cancel
Save