添加反转内容

pull/871/head^2
gedoor 4 years ago
parent c106b6baae
commit 68fc80abac
  1. 19
      app/src/main/java/io/legado/app/help/BookHelp.kt
  2. 3
      app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt
  3. 10
      app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt
  4. 5
      app/src/main/res/menu/book_read.xml
  5. 1
      app/src/main/res/values-zh-rHK/strings.xml
  6. 1
      app/src/main/res/values-zh-rTW/strings.xml
  7. 1
      app/src/main/res/values-zh/strings.xml
  8. 1
      app/src/main/res/values/strings.xml
  9. 2
      build.gradle

@ -191,6 +191,25 @@ object BookHelp {
return null return null
} }
fun reverseContent(book: Book, bookChapter: BookChapter) {
if (!book.isLocalBook()) {
val file = FileUtils.getFile(
downloadDir,
cacheFolderName,
book.getFolderName(),
bookChapter.getFileName()
)
if (file.exists()) {
val text = file.readText()
val stringBuilder = StringBuilder()
text.toStringArray().forEach {
stringBuilder.insert(0, it)
}
file.writeText(stringBuilder.toString())
}
}
}
fun delContent(book: Book, bookChapter: BookChapter) { fun delContent(book: Book, bookChapter: BookChapter) {
if (book.isLocalBook()) { if (book.isLocalBook()) {
return return

@ -242,6 +242,9 @@ class ReadBookActivity : ReadBookBaseActivity(),
supportFragmentManager, supportFragmentManager,
ReadBook.book?.tocUrl ReadBook.book?.tocUrl
) )
R.id.menu_reverse_content -> ReadBook.book?.let {
viewModel.reverseContent(it)
}
R.id.menu_set_charset -> showCharsetConfig() R.id.menu_set_charset -> showCharsetConfig()
R.id.menu_get_progress -> ReadBook.book?.let { R.id.menu_get_progress -> ReadBook.book?.let {
viewModel.syncBookProgress(it) { progress -> viewModel.syncBookProgress(it) { progress ->

@ -295,6 +295,16 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
} }
} }
fun reverseContent(book: Book) {
execute {
appDb.bookChapterDao.getChapter(book.bookUrl, ReadBook.durChapterIndex)
?.let { chapter ->
BookHelp.reverseContent(book, chapter)
ReadBook.loadContent(ReadBook.durChapterIndex, resetPageOffset = false)
}
}
}
/** /**
* 替换规则变化 * 替换规则变化
*/ */

@ -73,6 +73,11 @@
android:title="@string/get_book_progress" android:title="@string/get_book_progress"
app:showAsAction="never" /> app:showAsAction="never" />
<item
android:id="@+id/menu_reverse_content"
android:title="@string/reverse_content"
app:showAsAction="never" />
<item <item
android:id="@+id/menu_enable_replace" android:id="@+id/menu_enable_replace"
android:title="@string/replace_rule_title" android:title="@string/replace_rule_title"

@ -804,5 +804,6 @@
<string name="export_folder">导出文件夹</string> <string name="export_folder">导出文件夹</string>
<string name="export_charset">导出编码</string> <string name="export_charset">导出编码</string>
<string name="export_to_web_dav">导出到WebDav</string> <string name="export_to_web_dav">导出到WebDav</string>
<string name="reverse_content">反转内容</string>
</resources> </resources>

@ -808,5 +808,6 @@
<string name="export_folder">匯出資料夾</string> <string name="export_folder">匯出資料夾</string>
<string name="export_charset">匯出編碼</string> <string name="export_charset">匯出編碼</string>
<string name="export_to_web_dav">匯出到WebDav</string> <string name="export_to_web_dav">匯出到WebDav</string>
<string name="reverse_content">反转内容</string>
</resources> </resources>

@ -808,5 +808,6 @@
<string name="export_folder">导出文件夹</string> <string name="export_folder">导出文件夹</string>
<string name="export_charset">导出编码</string> <string name="export_charset">导出编码</string>
<string name="export_to_web_dav">导出到WebDav</string> <string name="export_to_web_dav">导出到WebDav</string>
<string name="reverse_content">反转内容</string>
</resources> </resources>

@ -811,5 +811,6 @@
<string name="export_folder">导出文件夹</string> <string name="export_folder">导出文件夹</string>
<string name="export_charset">导出编码</string> <string name="export_charset">导出编码</string>
<string name="export_to_web_dav">导出到WebDav</string> <string name="export_to_web_dav">导出到WebDav</string>
<string name="reverse_content">反转内容</string>
</resources> </resources>

@ -1,7 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules. // Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript { buildscript {
ext.kotlin_version = '1.4.30' ext.kotlin_version = '1.4.31'
repositories { repositories {
google() google()
jcenter() jcenter()

Loading…
Cancel
Save