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