pull/2498/head
kunfei 2 years ago
parent 232afd0c81
commit 06a4020970
  1. 44
      app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt
  2. 27
      app/src/main/java/io/legado/app/ui/book/read/config/ClickActionConfigDialog.kt
  3. 9
      app/src/main/java/io/legado/app/ui/book/read/page/ReadView.kt
  4. 1
      app/src/main/res/values-es-rES/strings.xml
  5. 1
      app/src/main/res/values-ja-rJP/strings.xml
  6. 1
      app/src/main/res/values-pt-rBR/strings.xml
  7. 1
      app/src/main/res/values-zh-rHK/strings.xml
  8. 1
      app/src/main/res/values-zh-rTW/strings.xml
  9. 1
      app/src/main/res/values-zh/strings.xml
  10. 1
      app/src/main/res/values/strings.xml

@ -352,19 +352,7 @@ class ReadBookActivity : BaseReadBookActivity(),
}
}
R.id.menu_download -> showDownloadDialog()
R.id.menu_add_bookmark -> {
val book = ReadBook.book
val page = ReadBook.curTextChapter?.getPage(ReadBook.durPageIndex)
if (book != null && page != null) {
val bookmark = book.createBookMark().apply {
chapterIndex = ReadBook.durChapterIndex
chapterPos = ReadBook.durChapterPos
chapterName = page.title
bookText = page.text.trim()
}
showDialogFragment(BookmarkDialog(bookmark))
}
}
R.id.menu_add_bookmark -> addBookmark()
R.id.menu_edit_content -> showDialogFragment(ContentEditDialog())
R.id.menu_update_toc -> ReadBook.book?.let {
if (it.isEpub) {
@ -372,12 +360,7 @@ class ReadBookActivity : BaseReadBookActivity(),
}
loadChapterList(it)
}
R.id.menu_enable_replace -> ReadBook.book?.let {
it.setUseReplaceRule(!it.getUseReplaceRule())
ReadBook.saveRead()
menu?.findItem(R.id.menu_enable_replace)?.isChecked = it.getUseReplaceRule()
viewModel.replaceRuleChanged()
}
R.id.menu_enable_replace -> changeReplaceRuleState()
R.id.menu_re_segment -> ReadBook.book?.let {
it.setReSegment(!it.getReSegment())
menu?.findItem(R.id.menu_re_segment)?.isChecked = it.getReSegment()
@ -1247,6 +1230,29 @@ class ReadBookActivity : BaseReadBookActivity(),
}
}
override fun addBookmark() {
val book = ReadBook.book
val page = ReadBook.curTextChapter?.getPage(ReadBook.durPageIndex)
if (book != null && page != null) {
val bookmark = book.createBookMark().apply {
chapterIndex = ReadBook.durChapterIndex
chapterPos = ReadBook.durChapterPos
chapterName = page.title
bookText = page.text.trim()
}
showDialogFragment(BookmarkDialog(bookmark))
}
}
override fun changeReplaceRuleState() {
ReadBook.book?.let {
it.setUseReplaceRule(!it.getUseReplaceRule())
ReadBook.saveRead()
menu?.findItem(R.id.menu_enable_replace)?.isChecked = it.getUseReplaceRule()
viewModel.replaceRuleChanged()
}
}
private fun startBackupJob() {
backupJob?.cancel()
backupJob = launch {

@ -22,19 +22,20 @@ import io.legado.app.utils.viewbindingdelegate.viewBinding
class ClickActionConfigDialog : BaseDialogFragment(R.layout.dialog_click_action_config) {
private val binding by viewBinding(DialogClickActionConfigBinding::bind)
private val actions by lazy {
linkedMapOf<Int, String>().apply {
this[-1] = getString(R.string.non_action)
this[0] = getString(R.string.menu)
this[1] = getString(R.string.next_page)
this[2] = getString(R.string.prev_page)
this[3] = getString(R.string.next_chapter)
this[4] = getString(R.string.previous_chapter)
this[5] = getString(R.string.read_aloud_prev_paragraph)
this[6] = getString(R.string.read_aloud_next_paragraph)
this[7] = getString(R.string.bookmark_add)
this[8] = getString(R.string.edit_content)
this[9] = getString(R.string.replace_rule)
}
linkedMapOf(
Pair(-1, getString(R.string.non_action)),
Pair(0, getString(R.string.menu)),
Pair(1, getString(R.string.next_page)),
Pair(2, getString(R.string.prev_page)),
Pair(3, getString(R.string.next_chapter)),
Pair(4, getString(R.string.previous_chapter)),
Pair(5, getString(R.string.read_aloud_prev_paragraph)),
Pair(6, getString(R.string.read_aloud_next_paragraph)),
Pair(7, getString(R.string.bookmark_add)),
Pair(8, getString(R.string.edit_content)),
Pair(9, getString(R.string.replace_state_change)),
Pair(10, getString(R.string.chapter_list))
)
}
override fun onStart() {

@ -18,6 +18,7 @@ import io.legado.app.help.config.ReadBookConfig
import io.legado.app.lib.theme.accentColor
import io.legado.app.model.ReadAloud
import io.legado.app.model.ReadBook
import io.legado.app.ui.book.read.ContentEditDialog
import io.legado.app.ui.book.read.page.api.DataSource
import io.legado.app.ui.book.read.page.delegate.*
import io.legado.app.ui.book.read.page.entities.PageDirection
@ -29,6 +30,7 @@ import io.legado.app.ui.book.read.page.provider.TextPageFactory
import io.legado.app.utils.activity
import io.legado.app.utils.invisible
import io.legado.app.utils.screenshot
import io.legado.app.utils.showDialogFragment
import java.text.BreakIterator
import java.util.*
import kotlin.math.abs
@ -418,6 +420,10 @@ class ReadView(context: Context, attrs: AttributeSet) :
4 -> ReadBook.moveToPrevChapter(upContent = true, toLast = false)
5 -> ReadAloud.prevParagraph(context)
6 -> ReadAloud.nextParagraph(context)
7 -> callBack.addBookmark()
8 -> activity?.showDialogFragment(ContentEditDialog())
9 -> callBack.changeReplaceRuleState()
10 -> callBack.openChapterList()
}
}
@ -645,5 +651,8 @@ class ReadView(context: Context, attrs: AttributeSet) :
fun screenOffTimerStart()
fun showTextActionMenu()
fun autoPageStop()
fun openChapterList()
fun addBookmark()
fun changeReplaceRuleState()
}
}

@ -1051,4 +1051,5 @@
<string name="copy_rule">拷贝规则</string>
<string name="paste_rule">粘贴规则</string>
<string name="groups_or_source">多分组/书源</string>
<string name="replace_state_change">替换(启用/禁用)</string>
</resources>

@ -1054,4 +1054,5 @@
<string name="copy_rule">拷贝规则</string>
<string name="paste_rule">粘贴规则</string>
<string name="groups_or_source">多分组/书源</string>
<string name="replace_state_change">替换(启用/禁用)</string>
</resources>

@ -1054,4 +1054,5 @@
<string name="copy_rule">拷贝规则</string>
<string name="paste_rule">粘贴规则</string>
<string name="groups_or_source">多分组/书源</string>
<string name="replace_state_change">替换(启用/禁用)</string>
</resources>

@ -1051,4 +1051,5 @@
<string name="copy_rule">拷贝规则</string>
<string name="paste_rule">粘贴规则</string>
<string name="groups_or_source">多分组/书源</string>
<string name="replace_state_change">替换(启用/禁用)</string>
</resources>

@ -1053,4 +1053,5 @@
<string name="copy_rule">拷贝规则</string>
<string name="paste_rule">粘贴规则</string>
<string name="groups_or_source">多分组/书源</string>
<string name="replace_state_change">替换(启用/禁用)</string>
</resources>

@ -1053,4 +1053,5 @@
<string name="copy_rule">拷贝规则</string>
<string name="paste_rule">粘贴规则</string>
<string name="groups_or_source">多分组/书源</string>
<string name="replace_state_change">替换(启用/禁用)</string>
</resources>

@ -1054,4 +1054,5 @@
<string name="copy_rule">拷贝规则</string>
<string name="paste_rule">粘贴规则</string>
<string name="groups_or_source">多分组/书源</string>
<string name="replace_state_change">替换(启用/禁用)</string>
</resources>

Loading…
Cancel
Save