mirror of
https://github.com/gedoor/legado.git
synced 2024-07-19 01:17:25 +08:00
优化
This commit is contained in:
parent
93029ed1a1
commit
d9e08cfed7
@ -27,6 +27,7 @@
|
||||
android:requestLegacyExternalStorage="true"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme.Light"
|
||||
android:enableOnBackInvokedCallback="true"
|
||||
tools:ignore="AllowBackup,GoogleAppIndexingWarning,UnusedAttribute">
|
||||
<!-- 主入口 -->
|
||||
<activity
|
||||
|
@ -7,6 +7,7 @@ import android.content.res.Configuration
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.view.*
|
||||
import androidx.activity.addCallback
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.appcompat.widget.PopupMenu
|
||||
import androidx.core.view.get
|
||||
@ -184,6 +185,28 @@ class ReadBookActivity : BaseReadBookActivity(),
|
||||
upScreenTimeOut()
|
||||
ReadBook.callBack?.notifyBookChanged()
|
||||
ReadBook.callBack = this
|
||||
onBackPressedDispatcher.addCallback(this) {
|
||||
if (isShowingSearchResult) {
|
||||
exitSearchMenu()
|
||||
restoreLastBookProcess()
|
||||
return@addCallback
|
||||
}
|
||||
//拦截返回供恢复阅读进度
|
||||
if (ReadBook.lastBookPress != null && confirmRestoreProcess != false) {
|
||||
restoreLastBookProcess()
|
||||
return@addCallback
|
||||
}
|
||||
if (BaseReadAloudService.isPlay()) {
|
||||
ReadAloud.pause(this@ReadBookActivity)
|
||||
toastOnUi(R.string.read_aloud_pause)
|
||||
return@addCallback
|
||||
}
|
||||
if (isAutoPage) {
|
||||
autoPageStop()
|
||||
return@addCallback
|
||||
}
|
||||
finish()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onPostCreate(savedInstanceState: Bundle?) {
|
||||
@ -544,35 +567,10 @@ class ReadBookActivity : BaseReadBookActivity(),
|
||||
return true
|
||||
}
|
||||
|
||||
keyCode == KeyEvent.KEYCODE_BACK -> {
|
||||
if (isShowingSearchResult) {
|
||||
exitSearchMenu()
|
||||
restoreLastBookProcess()
|
||||
return true
|
||||
}
|
||||
//拦截返回供恢复阅读进度
|
||||
if (ReadBook.lastBookPress != null && confirmRestoreProcess != false) {
|
||||
restoreLastBookProcess()
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.onKeyDown(keyCode, event)
|
||||
}
|
||||
|
||||
/**
|
||||
* 长按事件
|
||||
*/
|
||||
override fun onKeyLongPress(keyCode: Int, event: KeyEvent?): Boolean {
|
||||
when (keyCode) {
|
||||
KeyEvent.KEYCODE_BACK -> {
|
||||
finish()
|
||||
return true
|
||||
}
|
||||
}
|
||||
return super.onKeyLongPress(keyCode, event)
|
||||
}
|
||||
|
||||
/**
|
||||
* 松开按键事件
|
||||
*/
|
||||
@ -584,30 +582,6 @@ class ReadBookActivity : BaseReadBookActivity(),
|
||||
}
|
||||
}
|
||||
|
||||
KeyEvent.KEYCODE_BACK -> {
|
||||
event?.let {
|
||||
if ((event.flags and KeyEvent.FLAG_CANCELED_LONG_PRESS == 0)
|
||||
&& event.isTracking
|
||||
&& !event.isCanceled
|
||||
) {
|
||||
if (BaseReadAloudService.isPlay()) {
|
||||
ReadAloud.pause(this)
|
||||
toastOnUi(R.string.read_aloud_pause)
|
||||
return true
|
||||
}
|
||||
if (isAutoPage) {
|
||||
autoPageStop()
|
||||
return true
|
||||
}
|
||||
if (getPrefBoolean("disableReturnKey")) {
|
||||
if (menuLayoutIsVisible) {
|
||||
finish()
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.onKeyUp(keyCode, event)
|
||||
}
|
||||
|
@ -149,13 +149,6 @@
|
||||
app:iconSpaceReserved="false"
|
||||
app:isBottomBackground="true" />
|
||||
|
||||
<io.legado.app.lib.prefs.SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="disableReturnKey"
|
||||
android:title="@string/disable_return_key"
|
||||
app:iconSpaceReserved="false"
|
||||
app:isBottomBackground="true" />
|
||||
|
||||
<io.legado.app.lib.prefs.Preference
|
||||
android:key="customPageKey"
|
||||
android:title="@string/custom_page_key"
|
||||
|
Loading…
Reference in New Issue
Block a user