diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 1779f9c25..3e9c54ca2 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -35,7 +35,8 @@ + android:resource="@xml/shortcuts" + android:launchMode="singleTask" /> (R.layout.activity_boo override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean { when (keyCode) { KeyEvent.KEYCODE_BACK -> { - if (readAloudStatus == Status.PLAY) { - ReadAloud.pause(this) - toast(R.string.read_aloud_pause) - return true - } + event?.startTracking() } KeyEvent.KEYCODE_VOLUME_UP -> { if (volumeKeyPage(PageDelegate.Direction.PREV)) { @@ -216,6 +213,18 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo return super.onKeyDown(keyCode, event) } + override fun onKeyLongPress(keyCode: Int, event: KeyEvent?): Boolean { + when (keyCode) { + KeyEvent.KEYCODE_BACK -> { + page_view.snackbar("转到后台", "确定") { + startActivity() + } + return true + } + } + return super.onKeyLongPress(keyCode, event) + } + override fun onKeyUp(keyCode: Int, event: KeyEvent?): Boolean { when (keyCode) { KeyEvent.KEYCODE_VOLUME_UP, KeyEvent.KEYCODE_VOLUME_DOWN -> { @@ -223,6 +232,17 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo return true } } + KeyEvent.KEYCODE_BACK -> { + event?.let { + if ((event.flags and KeyEvent.FLAG_CANCELED_LONG_PRESS == 0)) { + if (readAloudStatus == Status.PLAY) { + ReadAloud.pause(this) + toast(R.string.read_aloud_pause) + return true + } + } + } + } } return super.onKeyUp(keyCode, event) }