diff --git a/app/src/main/java/io/legado/app/help/BookHelp.kt b/app/src/main/java/io/legado/app/help/BookHelp.kt
index fbf05f538..803d11a9a 100644
--- a/app/src/main/java/io/legado/app/help/BookHelp.kt
+++ b/app/src/main/java/io/legado/app/help/BookHelp.kt
@@ -191,6 +191,25 @@ object BookHelp {
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) {
if (book.isLocalBook()) {
return
diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt
index 9ec9fbaf3..732c1b902 100644
--- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt
+++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt
@@ -242,6 +242,9 @@ class ReadBookActivity : ReadBookBaseActivity(),
supportFragmentManager,
ReadBook.book?.tocUrl
)
+ R.id.menu_reverse_content -> ReadBook.book?.let {
+ viewModel.reverseContent(it)
+ }
R.id.menu_set_charset -> showCharsetConfig()
R.id.menu_get_progress -> ReadBook.book?.let {
viewModel.syncBookProgress(it) { progress ->
diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt
index 5fff40d5c..5b6281320 100644
--- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt
+++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt
@@ -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)
+ }
+ }
+ }
+
/**
* 替换规则变化
*/
diff --git a/app/src/main/res/menu/book_read.xml b/app/src/main/res/menu/book_read.xml
index b34861c5a..e2cdb3f45 100644
--- a/app/src/main/res/menu/book_read.xml
+++ b/app/src/main/res/menu/book_read.xml
@@ -73,6 +73,11 @@
android:title="@string/get_book_progress"
app:showAsAction="never" />
+
+
- 导出文件夹
导出编码
导出到WebDav
+ 反转内容
diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml
index 762318f9f..0f4e05286 100644
--- a/app/src/main/res/values-zh-rTW/strings.xml
+++ b/app/src/main/res/values-zh-rTW/strings.xml
@@ -808,5 +808,6 @@
匯出資料夾
匯出編碼
匯出到WebDav
+ 反转内容
diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml
index d4dad82b7..cf60feffd 100644
--- a/app/src/main/res/values-zh/strings.xml
+++ b/app/src/main/res/values-zh/strings.xml
@@ -808,5 +808,6 @@
导出文件夹
导出编码
导出到WebDav
+ 反转内容
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 227aeb400..0e1c150cd 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -811,5 +811,6 @@
导出文件夹
导出编码
导出到WebDav
+ 反转内容
diff --git a/build.gradle b/build.gradle
index e4a3e9d2e..228c51fa0 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,7 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
- ext.kotlin_version = '1.4.30'
+ ext.kotlin_version = '1.4.31'
repositories {
google()
jcenter()