This commit is contained in:
kunfei
2022-02-27 18:59:42 +08:00
parent fd2200ac06
commit 719be50ed5
14 changed files with 32 additions and 7 deletions
@@ -6,6 +6,7 @@ import io.legado.app.data.entities.Book
import io.legado.app.data.entities.BookChapter import io.legado.app.data.entities.BookChapter
import io.legado.app.data.entities.BookSource import io.legado.app.data.entities.BookSource
import io.legado.app.data.entities.rule.TocRule import io.legado.app.data.entities.rule.TocRule
import io.legado.app.help.ContentProcessor
import io.legado.app.model.Debug import io.legado.app.model.Debug
import io.legado.app.model.NoStackTraceException import io.legado.app.model.NoStackTraceException
import io.legado.app.model.TocEmptyException import io.legado.app.model.TocEmptyException
@@ -118,9 +119,10 @@ object BookChapterList {
list.forEachIndexed { index, bookChapter -> list.forEachIndexed { index, bookChapter ->
bookChapter.index = index bookChapter.index = index
} }
book.latestChapterTitle = list.last().title val replaceRules = ContentProcessor.get(book.name, book.origin).getTitleReplaceRules()
book.durChapterTitle = book.latestChapterTitle = list.last().getDisplayTitle(replaceRules)
list.getOrNull(book.durChapterIndex)?.title ?: book.latestChapterTitle book.durChapterTitle = list.getOrElse(book.durChapterIndex) { list.last() }
.getDisplayTitle(replaceRules)
if (book.totalChapterNum < list.size) { if (book.totalChapterNum < list.size) {
book.lastCheckCount = list.size - book.totalChapterNum book.lastCheckCount = list.size - book.totalChapterNum
book.latestChapterTime = System.currentTimeMillis() book.latestChapterTime = System.currentTimeMillis()
@@ -10,6 +10,7 @@ import io.legado.app.data.entities.Book
import io.legado.app.data.entities.BookChapter import io.legado.app.data.entities.BookChapter
import io.legado.app.data.entities.BookSource import io.legado.app.data.entities.BookSource
import io.legado.app.help.BookHelp import io.legado.app.help.BookHelp
import io.legado.app.help.ContentProcessor
import io.legado.app.model.AudioPlay import io.legado.app.model.AudioPlay
import io.legado.app.model.webBook.WebBook import io.legado.app.model.webBook.WebBook
import io.legado.app.utils.postEvent import io.legado.app.utils.postEvent
@@ -120,7 +121,9 @@ class AudioPlayViewModel(application: Application) : BaseViewModel(application)
chapters, chapters,
oldTocSize oldTocSize
) )
book.durChapterTitle = chapters[book.durChapterIndex].title book.durChapterTitle = chapters[book.durChapterIndex].getDisplayTitle(
ContentProcessor.get(book.name, book.origin).getTitleReplaceRules()
)
appDb.bookDao.update(book) appDb.bookDao.update(book)
appDb.bookChapterDao.insert(*chapters.toTypedArray()) appDb.bookChapterDao.insert(*chapters.toTypedArray())
} }
@@ -13,6 +13,7 @@ import io.legado.app.data.entities.Book
import io.legado.app.data.entities.BookChapter import io.legado.app.data.entities.BookChapter
import io.legado.app.data.entities.BookSource import io.legado.app.data.entities.BookSource
import io.legado.app.help.BookHelp import io.legado.app.help.BookHelp
import io.legado.app.help.ContentProcessor
import io.legado.app.help.coroutine.Coroutine import io.legado.app.help.coroutine.Coroutine
import io.legado.app.model.NoStackTraceException import io.legado.app.model.NoStackTraceException
import io.legado.app.model.ReadBook import io.legado.app.model.ReadBook
@@ -208,7 +209,9 @@ class BookInfoViewModel(application: Application) : BaseViewModel(application) {
chapters, chapters,
oldTocSize oldTocSize
) )
book.durChapterTitle = chapters[book.durChapterIndex].title book.durChapterTitle = chapters[book.durChapterIndex].getDisplayTitle(
ContentProcessor.get(book.name, book.origin).getTitleReplaceRules()
)
if (inBookshelf) { if (inBookshelf) {
appDb.bookDao.update(book) appDb.bookDao.update(book)
appDb.bookChapterDao.insert(*chapters.toTypedArray()) appDb.bookChapterDao.insert(*chapters.toTypedArray())
@@ -19,6 +19,7 @@ import io.legado.app.lib.theme.primaryColor
import io.legado.app.model.ReadBook import io.legado.app.model.ReadBook
import io.legado.app.model.webBook.WebBook import io.legado.app.model.webBook.WebBook
import io.legado.app.utils.applyTint import io.legado.app.utils.applyTint
import io.legado.app.utils.sendToClip
import io.legado.app.utils.setLayout import io.legado.app.utils.setLayout
import io.legado.app.utils.viewbindingdelegate.viewBinding import io.legado.app.utils.viewbindingdelegate.viewBinding
import kotlinx.coroutines.Dispatchers.IO import kotlinx.coroutines.Dispatchers.IO
@@ -78,6 +79,8 @@ class ContentEditDialog : BaseDialogFragment(R.layout.dialog_content_edit) {
binding.contentView.setText(content) binding.contentView.setText(content)
ReadBook.loadContent(ReadBook.durChapterIndex, resetPageOffset = false) ReadBook.loadContent(ReadBook.durChapterIndex, resetPageOffset = false)
} }
R.id.menu_copy_all -> requireContext()
.sendToClip("${binding.toolBar.title}\n${viewModel.content}")
} }
return@setOnMenuItemClickListener true return@setOnMenuItemClickListener true
} }
@@ -189,7 +189,9 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
chapters, chapters,
oldBook.totalChapterNum oldBook.totalChapterNum
) )
book.durChapterTitle = chapters[book.durChapterIndex].title book.durChapterTitle = chapters[book.durChapterIndex].getDisplayTitle(
ContentProcessor.get(book.name, book.origin).getTitleReplaceRules()
)
oldBook.changeTo(book) oldBook.changeTo(book)
appDb.bookChapterDao.insert(*chapters.toTypedArray()) appDb.bookChapterDao.insert(*chapters.toTypedArray())
ReadBook.resetData(book) ReadBook.resetData(book)
@@ -11,7 +11,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:theme="?attr/actionBarStyle" android:theme="?attr/actionBarStyle"
app:title="code edit" app:title="edit"
app:popupTheme="@style/AppTheme.PopupOverlay" app:popupTheme="@style/AppTheme.PopupOverlay"
app:titleTextAppearance="@style/ToolbarTitle" /> app:titleTextAppearance="@style/ToolbarTitle" />
+5
View File
@@ -15,4 +15,9 @@
android:title="@string/reset" android:title="@string/reset"
app:showAsAction="never" /> app:showAsAction="never" />
<item
android:id="@+id/menu_copy_all"
android:title="@string/copy_all"
app:showAsAction="never" />
</menu> </menu>
@@ -943,5 +943,6 @@
<string name="book_change_source">整书换源</string> <string name="book_change_source">整书换源</string>
<string name="sort_by_time">时间排序</string> <string name="sort_by_time">时间排序</string>
<string name="enable_record">开启记录</string> <string name="enable_record">开启记录</string>
<string name="copy_all">拷贝所有</string>
<!-- string end --> <!-- string end -->
</resources> </resources>
@@ -946,5 +946,6 @@
<string name="book_change_source">整书换源</string> <string name="book_change_source">整书换源</string>
<string name="sort_by_time">时间排序</string> <string name="sort_by_time">时间排序</string>
<string name="enable_record">开启记录</string> <string name="enable_record">开启记录</string>
<string name="copy_all">拷贝所有</string>
<!-- string end --> <!-- string end -->
</resources> </resources>
@@ -946,5 +946,6 @@
<string name="book_change_source">整书换源</string> <string name="book_change_source">整书换源</string>
<string name="sort_by_time">时间排序</string> <string name="sort_by_time">时间排序</string>
<string name="enable_record">开启记录</string> <string name="enable_record">开启记录</string>
<string name="copy_all">拷贝所有</string>
<!-- string end --> <!-- string end -->
</resources> </resources>
@@ -943,5 +943,6 @@
<string name="book_change_source">整书换源</string> <string name="book_change_source">整书换源</string>
<string name="sort_by_time">时间排序</string> <string name="sort_by_time">时间排序</string>
<string name="enable_record">开启记录</string> <string name="enable_record">开启记录</string>
<string name="copy_all">拷贝所有</string>
<!-- string end --> <!-- string end -->
</resources> </resources>
@@ -945,5 +945,6 @@
<string name="book_change_source">整书换源</string> <string name="book_change_source">整书换源</string>
<string name="sort_by_time">时间排序</string> <string name="sort_by_time">时间排序</string>
<string name="enable_record">开启记录</string> <string name="enable_record">开启记录</string>
<string name="copy_all">拷贝所有</string>
<!-- string end --> <!-- string end -->
</resources> </resources>
+1
View File
@@ -945,5 +945,6 @@
<string name="book_change_source">整书换源</string> <string name="book_change_source">整书换源</string>
<string name="sort_by_time">时间排序</string> <string name="sort_by_time">时间排序</string>
<string name="enable_record">开启记录</string> <string name="enable_record">开启记录</string>
<string name="copy_all">拷贝所有</string>
<!-- string end --> <!-- string end -->
</resources> </resources>
+1
View File
@@ -946,5 +946,6 @@
<string name="book_change_source">整书换源</string> <string name="book_change_source">整书换源</string>
<string name="sort_by_time">时间排序</string> <string name="sort_by_time">时间排序</string>
<string name="enable_record">开启记录</string> <string name="enable_record">开启记录</string>
<string name="copy_all">拷贝所有</string>
<!-- string end --> <!-- string end -->
</resources> </resources>