pull/436/head
gedoor 4 years ago
parent 86dabae7d3
commit 717c90a6d1
  1. 4
      app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt
  2. 12
      app/src/main/java/io/legado/app/ui/book/read/ReadBookActivityHelp.kt

@ -314,13 +314,13 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_boo
*/
override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean {
when {
getPrefString(PreferKey.prevKeys)?.contains(keyCode.toString()) == true -> {
ReadBookActivityHelp.isPrevKey(this, keyCode) -> {
if (keyCode != KeyEvent.KEYCODE_UNKNOWN) {
page_view.pageDelegate?.keyTurnPage(PageDelegate.Direction.PREV)
return true
}
}
getPrefString(PreferKey.nextKeys)?.contains(keyCode.toString()) == true -> {
ReadBookActivityHelp.isNextKey(this, keyCode) -> {
if (keyCode != KeyEvent.KEYCODE_UNKNOWN) {
page_view.pageDelegate?.keyTurnPage(PageDelegate.Direction.NEXT)
return true

@ -13,6 +13,7 @@ import android.view.WindowManager
import android.widget.EditText
import io.legado.app.App
import io.legado.app.R
import io.legado.app.constant.PreferKey
import io.legado.app.data.entities.Bookmark
import io.legado.app.help.AppConfig
import io.legado.app.help.ReadBookConfig
@ -24,6 +25,7 @@ import io.legado.app.service.help.CacheBook
import io.legado.app.service.help.ReadBook
import io.legado.app.ui.widget.text.AutoCompleteTextView
import io.legado.app.utils.applyTint
import io.legado.app.utils.getPrefString
import io.legado.app.utils.requestInputMethod
import kotlinx.android.synthetic.main.dialog_download_choice.view.*
import kotlinx.android.synthetic.main.dialog_edit_text.view.*
@ -186,4 +188,14 @@ object ReadBookActivityHelp {
cancelButton()
}.show().applyTint()
}
fun isPrevKey(context: Context, keyCode: Int): Boolean {
val prevKeysStr = context.getPrefString(PreferKey.prevKeys)
return prevKeysStr?.split(",")?.contains(keyCode.toString()) ?: false
}
fun isNextKey(context: Context, keyCode: Int): Boolean {
val nextKeysStr = context.getPrefString(PreferKey.nextKeys)
return nextKeysStr?.split(",")?.contains(keyCode.toString()) ?: false
}
}
Loading…
Cancel
Save