mirror of
https://github.com/gedoor/legado.git
synced 2024-08-30 09:23:26 +08:00
优化
This commit is contained in:
parent
36eb6bec24
commit
456188a8c8
@ -140,6 +140,9 @@ object PreferKey {
|
|||||||
const val showBookshelfFastScroller = "showBookshelfFastScroller"
|
const val showBookshelfFastScroller = "showBookshelfFastScroller"
|
||||||
const val importKeepEnable = "importKeepEnable"
|
const val importKeepEnable = "importKeepEnable"
|
||||||
const val previewImageByClick = "previewImageByClick"
|
const val previewImageByClick = "previewImageByClick"
|
||||||
|
const val volumeKeyPageOnLongPress = "volumeKeyPageOnLongPress"
|
||||||
|
const val volumeKeyPage = "volumeKeyPage"
|
||||||
|
const val volumeKeyPageOnPlay = "volumeKeyPageOnPlay"
|
||||||
|
|
||||||
const val cPrimary = "colorPrimary"
|
const val cPrimary = "colorPrimary"
|
||||||
const val cAccent = "colorAccent"
|
const val cAccent = "colorAccent"
|
||||||
|
@ -331,6 +331,7 @@ data class Book(
|
|||||||
appDb.bookDao.delete(this)
|
appDb.bookDao.delete(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("ConstPropertyName")
|
||||||
companion object {
|
companion object {
|
||||||
const val hTag = 2L
|
const val hTag = 2L
|
||||||
const val rubyTag = 4L
|
const val rubyTag = 4L
|
||||||
|
@ -21,7 +21,7 @@ import io.legado.app.utils.sysConfiguration
|
|||||||
import io.legado.app.utils.toastOnUi
|
import io.legado.app.utils.toastOnUi
|
||||||
import splitties.init.appCtx
|
import splitties.init.appCtx
|
||||||
|
|
||||||
@Suppress("MemberVisibilityCanBePrivate")
|
@Suppress("MemberVisibilityCanBePrivate", "ConstPropertyName")
|
||||||
object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener {
|
object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener {
|
||||||
val isCronet = appCtx.getPrefBoolean(PreferKey.cronet)
|
val isCronet = appCtx.getPrefBoolean(PreferKey.cronet)
|
||||||
var useAntiAlias = appCtx.getPrefBoolean(PreferKey.antiAlias)
|
var useAntiAlias = appCtx.getPrefBoolean(PreferKey.antiAlias)
|
||||||
@ -468,6 +468,15 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener {
|
|||||||
val progressBarBehavior: String?
|
val progressBarBehavior: String?
|
||||||
get() = appCtx.getPrefString(PreferKey.progressBarBehavior, "page")
|
get() = appCtx.getPrefString(PreferKey.progressBarBehavior, "page")
|
||||||
|
|
||||||
|
val volumeKeyPageOnLongPress
|
||||||
|
get() = appCtx.getPrefBoolean(PreferKey.volumeKeyPageOnLongPress, false)
|
||||||
|
|
||||||
|
val volumeKeyPage
|
||||||
|
get() = appCtx.getPrefBoolean(PreferKey.volumeKeyPage, true)
|
||||||
|
|
||||||
|
val volumeKeyPageOnPlay
|
||||||
|
get() = appCtx.getPrefBoolean(PreferKey.volumeKeyPageOnPlay, true)
|
||||||
|
|
||||||
var searchScope: String
|
var searchScope: String
|
||||||
get() = appCtx.getPrefString("searchScope") ?: ""
|
get() = appCtx.getPrefString("searchScope") ?: ""
|
||||||
set(value) {
|
set(value) {
|
||||||
|
@ -48,9 +48,12 @@ import io.legado.app.ui.book.audio.AudioPlayActivity
|
|||||||
import io.legado.app.ui.book.bookmark.BookmarkDialog
|
import io.legado.app.ui.book.bookmark.BookmarkDialog
|
||||||
import io.legado.app.ui.book.changesource.ChangeBookSourceDialog
|
import io.legado.app.ui.book.changesource.ChangeBookSourceDialog
|
||||||
import io.legado.app.ui.book.changesource.ChangeChapterSourceDialog
|
import io.legado.app.ui.book.changesource.ChangeChapterSourceDialog
|
||||||
import io.legado.app.ui.book.read.config.*
|
import io.legado.app.ui.book.read.config.AutoReadDialog
|
||||||
import io.legado.app.ui.book.read.config.BgTextConfigDialog.Companion.BG_COLOR
|
import io.legado.app.ui.book.read.config.BgTextConfigDialog.Companion.BG_COLOR
|
||||||
import io.legado.app.ui.book.read.config.BgTextConfigDialog.Companion.TEXT_COLOR
|
import io.legado.app.ui.book.read.config.BgTextConfigDialog.Companion.TEXT_COLOR
|
||||||
|
import io.legado.app.ui.book.read.config.MoreConfigDialog
|
||||||
|
import io.legado.app.ui.book.read.config.ReadAloudDialog
|
||||||
|
import io.legado.app.ui.book.read.config.ReadStyleDialog
|
||||||
import io.legado.app.ui.book.read.config.TipConfigDialog.Companion.TIP_COLOR
|
import io.legado.app.ui.book.read.config.TipConfigDialog.Companion.TIP_COLOR
|
||||||
import io.legado.app.ui.book.read.config.TipConfigDialog.Companion.TIP_DIVIDER_COLOR
|
import io.legado.app.ui.book.read.config.TipConfigDialog.Companion.TIP_DIVIDER_COLOR
|
||||||
import io.legado.app.ui.book.read.page.ContentTextView
|
import io.legado.app.ui.book.read.page.ContentTextView
|
||||||
@ -570,7 +573,7 @@ class ReadBookActivity : BaseReadBookActivity(),
|
|||||||
/**
|
/**
|
||||||
* 按键事件
|
* 按键事件
|
||||||
*/
|
*/
|
||||||
override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean {
|
override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {
|
||||||
if (menuLayoutIsVisible) {
|
if (menuLayoutIsVisible) {
|
||||||
return super.onKeyDown(keyCode, event)
|
return super.onKeyDown(keyCode, event)
|
||||||
}
|
}
|
||||||
@ -592,13 +595,13 @@ class ReadBookActivity : BaseReadBookActivity(),
|
|||||||
}
|
}
|
||||||
|
|
||||||
keyCode == KeyEvent.KEYCODE_VOLUME_UP -> {
|
keyCode == KeyEvent.KEYCODE_VOLUME_UP -> {
|
||||||
if (volumeKeyPage(PageDirection.PREV)) {
|
if (volumeKeyPage(PageDirection.PREV, event.repeatCount > 0)) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
keyCode == KeyEvent.KEYCODE_VOLUME_DOWN -> {
|
keyCode == KeyEvent.KEYCODE_VOLUME_DOWN -> {
|
||||||
if (volumeKeyPage(PageDirection.NEXT)) {
|
if (volumeKeyPage(PageDirection.NEXT, event.repeatCount > 0)) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -628,10 +631,10 @@ class ReadBookActivity : BaseReadBookActivity(),
|
|||||||
/**
|
/**
|
||||||
* 松开按键事件
|
* 松开按键事件
|
||||||
*/
|
*/
|
||||||
override fun onKeyUp(keyCode: Int, event: KeyEvent?): Boolean {
|
override fun onKeyUp(keyCode: Int, event: KeyEvent): Boolean {
|
||||||
when (keyCode) {
|
when (keyCode) {
|
||||||
KeyEvent.KEYCODE_VOLUME_UP, KeyEvent.KEYCODE_VOLUME_DOWN -> {
|
KeyEvent.KEYCODE_VOLUME_UP, KeyEvent.KEYCODE_VOLUME_DOWN -> {
|
||||||
if (volumeKeyPage(PageDirection.NONE)) {
|
if (volumeKeyPage(PageDirection.NONE, event.repeatCount > 0)) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -824,20 +827,23 @@ class ReadBookActivity : BaseReadBookActivity(),
|
|||||||
/**
|
/**
|
||||||
* 音量键翻页
|
* 音量键翻页
|
||||||
*/
|
*/
|
||||||
private fun volumeKeyPage(direction: PageDirection): Boolean {
|
private fun volumeKeyPage(direction: PageDirection, longPress: Boolean): Boolean {
|
||||||
if (!binding.readMenu.isVisible) {
|
if (menuLayoutIsVisible) {
|
||||||
if (getPrefBoolean("volumeKeyPage", true)) {
|
return false
|
||||||
if (getPrefBoolean("volumeKeyPageOnPlay")
|
|
||||||
|| !BaseReadAloudService.isPlay()
|
|
||||||
) {
|
|
||||||
binding.readView.cancelSelect()
|
|
||||||
binding.readView.pageDelegate?.isCancel = false
|
|
||||||
binding.readView.pageDelegate?.keyTurnPage(direction)
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false
|
if (!AppConfig.volumeKeyPage) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if (!AppConfig.volumeKeyPageOnPlay && BaseReadAloudService.isPlay()) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if (!AppConfig.volumeKeyPageOnLongPress && longPress) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
binding.readView.cancelSelect()
|
||||||
|
binding.readView.pageDelegate?.isCancel = false
|
||||||
|
binding.readView.pageDelegate?.keyTurnPage(direction)
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun upMenuView() {
|
override fun upMenuView() {
|
||||||
|
@ -49,8 +49,8 @@
|
|||||||
<string-array name="screen_time_out">
|
<string-array name="screen_time_out">
|
||||||
<item>Predeterminado</item>
|
<item>Predeterminado</item>
|
||||||
<item>1 min</item>
|
<item>1 min</item>
|
||||||
<item>2 min</item>
|
<item>5 min</item>
|
||||||
<item>3 min</item>
|
<item>10 min</item>
|
||||||
<item>Siempre</item>
|
<item>Siempre</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
|
@ -1139,4 +1139,5 @@
|
|||||||
<string name="adjust_chapter_page">调整本章页数</string>
|
<string name="adjust_chapter_page">调整本章页数</string>
|
||||||
<string name="adjust_chapter_index">调整章节位置</string>
|
<string name="adjust_chapter_index">调整章节位置</string>
|
||||||
<string name="clear_webview_data_success">清除成功,3秒后自动重启应用</string>
|
<string name="clear_webview_data_success">清除成功,3秒后自动重启应用</string>
|
||||||
|
<string name="volume_key_page_on_long_press">长按音量键翻页</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -1142,4 +1142,5 @@
|
|||||||
<string name="adjust_chapter_page">调整本章页数</string>
|
<string name="adjust_chapter_page">调整本章页数</string>
|
||||||
<string name="adjust_chapter_index">调整章节位置</string>
|
<string name="adjust_chapter_index">调整章节位置</string>
|
||||||
<string name="clear_webview_data_success">清除成功,3秒后自动重启应用</string>
|
<string name="clear_webview_data_success">清除成功,3秒后自动重启应用</string>
|
||||||
|
<string name="volume_key_page_on_long_press">长按音量键翻页</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -49,8 +49,8 @@
|
|||||||
<string-array name="screen_time_out">
|
<string-array name="screen_time_out">
|
||||||
<item>Padrão</item>
|
<item>Padrão</item>
|
||||||
<item>1 min</item>
|
<item>1 min</item>
|
||||||
<item>2 min</item>
|
<item>5 min</item>
|
||||||
<item>3 min</item>
|
<item>10 min</item>
|
||||||
<item>Sempre</item>
|
<item>Sempre</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
|
@ -1142,4 +1142,5 @@
|
|||||||
<string name="adjust_chapter_page">调整本章页数</string>
|
<string name="adjust_chapter_page">调整本章页数</string>
|
||||||
<string name="adjust_chapter_index">调整章节位置</string>
|
<string name="adjust_chapter_index">调整章节位置</string>
|
||||||
<string name="clear_webview_data_success">清除成功,3秒后自动重启应用</string>
|
<string name="clear_webview_data_success">清除成功,3秒后自动重启应用</string>
|
||||||
|
<string name="volume_key_page_on_long_press">长按音量键翻页</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -36,8 +36,8 @@
|
|||||||
<string-array name="screen_time_out">
|
<string-array name="screen_time_out">
|
||||||
<item>Mặc định</item>
|
<item>Mặc định</item>
|
||||||
<item>1 phút</item>
|
<item>1 phút</item>
|
||||||
<item>2 phút</item>
|
<item>5 phút</item>
|
||||||
<item>3 phút</item>
|
<item>10 phút</item>
|
||||||
<item>Thường Sáng</item>
|
<item>Thường Sáng</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
|
@ -1138,4 +1138,5 @@ Còn </string>
|
|||||||
<string name="adjust_chapter_page">调整本章页数</string>
|
<string name="adjust_chapter_page">调整本章页数</string>
|
||||||
<string name="adjust_chapter_index">调整章节位置</string>
|
<string name="adjust_chapter_index">调整章节位置</string>
|
||||||
<string name="clear_webview_data_success">清除成功,3秒后自动重启应用</string>
|
<string name="clear_webview_data_success">清除成功,3秒后自动重启应用</string>
|
||||||
|
<string name="volume_key_page_on_long_press">长按音量键翻页</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -30,8 +30,8 @@
|
|||||||
<string-array name="screen_time_out">
|
<string-array name="screen_time_out">
|
||||||
<item>默認</item>
|
<item>默認</item>
|
||||||
<item>1分鐘</item>
|
<item>1分鐘</item>
|
||||||
<item>2分鐘</item>
|
<item>5分鐘</item>
|
||||||
<item>3分鐘</item>
|
<item>10分鐘</item>
|
||||||
<item>常亮</item>
|
<item>常亮</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
|
@ -1139,4 +1139,5 @@
|
|||||||
<string name="adjust_chapter_page">调整本章页数</string>
|
<string name="adjust_chapter_page">调整本章页数</string>
|
||||||
<string name="adjust_chapter_index">调整章节位置</string>
|
<string name="adjust_chapter_index">调整章节位置</string>
|
||||||
<string name="clear_webview_data_success">清除成功,3秒后自动重启应用</string>
|
<string name="clear_webview_data_success">清除成功,3秒后自动重启应用</string>
|
||||||
|
<string name="volume_key_page_on_long_press">长按音量键翻页</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -35,8 +35,8 @@
|
|||||||
<string-array name="screen_time_out">
|
<string-array name="screen_time_out">
|
||||||
<item>預設</item>
|
<item>預設</item>
|
||||||
<item>1分鐘</item>
|
<item>1分鐘</item>
|
||||||
<item>2分鐘</item>
|
<item>5分鐘</item>
|
||||||
<item>3分鐘</item>
|
<item>10分鐘</item>
|
||||||
<item>常亮</item>
|
<item>常亮</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
|
@ -1141,4 +1141,5 @@
|
|||||||
<string name="adjust_chapter_page">调整本章页数</string>
|
<string name="adjust_chapter_page">调整本章页数</string>
|
||||||
<string name="adjust_chapter_index">调整章节位置</string>
|
<string name="adjust_chapter_index">调整章节位置</string>
|
||||||
<string name="clear_webview_data_success">清除成功,3秒后自动重启应用</string>
|
<string name="clear_webview_data_success">清除成功,3秒后自动重启应用</string>
|
||||||
|
<string name="volume_key_page_on_long_press">长按音量键翻页</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -42,8 +42,8 @@
|
|||||||
<string-array name="screen_time_out">
|
<string-array name="screen_time_out">
|
||||||
<item>默认</item>
|
<item>默认</item>
|
||||||
<item>1分钟</item>
|
<item>1分钟</item>
|
||||||
<item>2分钟</item>
|
<item>5分钟</item>
|
||||||
<item>3分钟</item>
|
<item>10分钟</item>
|
||||||
<item>常亮</item>
|
<item>常亮</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
|
@ -1141,4 +1141,5 @@
|
|||||||
<string name="adjust_chapter_page">调整本章页数</string>
|
<string name="adjust_chapter_page">调整本章页数</string>
|
||||||
<string name="adjust_chapter_index">调整章节位置</string>
|
<string name="adjust_chapter_index">调整章节位置</string>
|
||||||
<string name="clear_webview_data_success">清除成功,3秒后自动重启应用</string>
|
<string name="clear_webview_data_success">清除成功,3秒后自动重启应用</string>
|
||||||
|
<string name="volume_key_page_on_long_press">长按音量键翻页</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -14,8 +14,8 @@
|
|||||||
<string-array name="screen_time_out_value">
|
<string-array name="screen_time_out_value">
|
||||||
<item>0</item>
|
<item>0</item>
|
||||||
<item>60</item>
|
<item>60</item>
|
||||||
<item>120</item>
|
<item>300</item>
|
||||||
<item>180</item>
|
<item>600</item>
|
||||||
<item>-1</item>
|
<item>-1</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
|
@ -63,8 +63,8 @@
|
|||||||
<string-array name="screen_time_out">
|
<string-array name="screen_time_out">
|
||||||
<item>Default</item>
|
<item>Default</item>
|
||||||
<item>1 min</item>
|
<item>1 min</item>
|
||||||
<item>2 min</item>
|
<item>5 min</item>
|
||||||
<item>3 min</item>
|
<item>10 min</item>
|
||||||
<item>Always</item>
|
<item>Always</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
|
@ -1142,4 +1142,5 @@
|
|||||||
<string name="adjust_chapter_page">Adjust of chapter page</string>
|
<string name="adjust_chapter_page">Adjust of chapter page</string>
|
||||||
<string name="adjust_chapter_index">Adjust of chapter index</string>
|
<string name="adjust_chapter_index">Adjust of chapter index</string>
|
||||||
<string name="clear_webview_data_success">Cleared successfully, automatically restarts the application after 3 seconds</string>
|
<string name="clear_webview_data_success">Cleared successfully, automatically restarts the application after 3 seconds</string>
|
||||||
|
<string name="volume_key_page_on_long_press">Press and hold the volume key to turn the page</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -101,6 +101,13 @@
|
|||||||
app:iconSpaceReserved="false"
|
app:iconSpaceReserved="false"
|
||||||
app:isBottomBackground="true" />
|
app:isBottomBackground="true" />
|
||||||
|
|
||||||
|
<io.legado.app.lib.prefs.SwitchPreference
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:key="volumeKeyPageOnLongPress"
|
||||||
|
android:title="@string/volume_key_page_on_long_press"
|
||||||
|
app:iconSpaceReserved="false"
|
||||||
|
app:isBottomBackground="true" />
|
||||||
|
|
||||||
<io.legado.app.lib.prefs.Preference
|
<io.legado.app.lib.prefs.Preference
|
||||||
android:key="pageTouchSlop"
|
android:key="pageTouchSlop"
|
||||||
android:summary="@string/page_touch_slop_summary"
|
android:summary="@string/page_touch_slop_summary"
|
||||||
|
Loading…
Reference in New Issue
Block a user