From 1172c3507673ffca34c8d24452f8ac7749337f42 Mon Sep 17 00:00:00 2001
From: Horis <821938089@qq.com>
Date: Tue, 17 Jan 2023 21:48:15 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/src/main/AndroidManifest.xml | 13 +++++++------
app/src/main/java/io/legado/app/model/ReadBook.kt | 2 +-
.../java/io/legado/app/model/localBook/LocalBook.kt | 4 ++--
.../app/ui/association/FileAssociationActivity.kt | 7 +++++--
.../io/legado/app/ui/book/read/ReadBookActivity.kt | 4 ++--
.../io/legado/app/ui/book/read/ReadBookViewModel.kt | 6 +-----
6 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index f988cad4e..da94ce43d 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -356,6 +356,8 @@
+
+
@@ -372,14 +374,13 @@
-
-
+
-
-
+
-
-
+
+
+
diff --git a/app/src/main/java/io/legado/app/model/ReadBook.kt b/app/src/main/java/io/legado/app/model/ReadBook.kt
index 540cc7756..2da67c7c8 100644
--- a/app/src/main/java/io/legado/app/model/ReadBook.kt
+++ b/app/src/main/java/io/legado/app/model/ReadBook.kt
@@ -501,7 +501,7 @@ object ReadBook : CoroutineScope by MainScope() {
interface CallBack {
fun upMenuView()
- fun loadChapterList(book: Book, callback: (() -> Unit)? = null)
+ fun loadChapterList(book: Book)
fun upContent(
relativePosition: Int = 0,
diff --git a/app/src/main/java/io/legado/app/model/localBook/LocalBook.kt b/app/src/main/java/io/legado/app/model/localBook/LocalBook.kt
index 877f6ae05..acfdd69ab 100644
--- a/app/src/main/java/io/legado/app/model/localBook/LocalBook.kt
+++ b/app/src/main/java/io/legado/app/model/localBook/LocalBook.kt
@@ -154,7 +154,7 @@ object LocalBook {
val bookUrl: String
val updateTime: Long
//这个变量不要修改,否则会导致读取不到缓存
- val fileName = (if (uri.isContentScheme()) {
+ val fileName = if (uri.isContentScheme()) {
bookUrl = uri.toString()
val doc = DocumentFile.fromSingleUri(appCtx, uri)!!
updateTime = doc.lastModified()
@@ -164,7 +164,7 @@ object LocalBook {
val file = File(bookUrl)
updateTime = file.lastModified()
file.name
- })
+ }
var book = appDb.bookDao.getBook(bookUrl)
if (book == null) {
val nameAuthor = analyzeNameAuthor(fileName)
diff --git a/app/src/main/java/io/legado/app/ui/association/FileAssociationActivity.kt b/app/src/main/java/io/legado/app/ui/association/FileAssociationActivity.kt
index cf3b96bd6..bd3e04b41 100644
--- a/app/src/main/java/io/legado/app/ui/association/FileAssociationActivity.kt
+++ b/app/src/main/java/io/legado/app/ui/association/FileAssociationActivity.kt
@@ -1,6 +1,7 @@
package io.legado.app.ui.association
import android.net.Uri
+import android.os.Build
import android.os.Bundle
import androidx.activity.viewModels
import androidx.documentfile.provider.DocumentFile
@@ -104,7 +105,9 @@ class FileAssociationActivity :
}
}
intent.data?.let { data ->
- if (!data.isContentScheme()) {
+ if (data.isContentScheme()) {
+ viewModel.dispatchIndent(data)
+ } else if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.Q) {
PermissionsCompat.Builder(this)
.addPermissions(*Permissions.Group.STORAGE)
.rationale(R.string.tip_perm_request_storage)
@@ -112,7 +115,7 @@ class FileAssociationActivity :
viewModel.dispatchIndent(data)
}.request()
} else {
- viewModel.dispatchIndent(data)
+ toastOnUi("由于安卓系统限制,请使用系统文件管理重新打开。")
}
}
}
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 6b700b8bc..11558542d 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
@@ -750,9 +750,9 @@ class ReadBookActivity : BaseReadBookActivity(),
}
}
- override fun loadChapterList(book: Book, callback: (() -> Unit)?) {
+ override fun loadChapterList(book: Book) {
ReadBook.upMsg(getString(R.string.toc_updateing))
- viewModel.loadChapterList(book, callback)
+ viewModel.loadChapterList(book)
}
/**
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 fa2e820c4..aeb31f6fc 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
@@ -134,7 +134,7 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
/**
* 加载目录
*/
- fun loadChapterList(book: Book, callback: (() -> Unit)? = null) {
+ fun loadChapterList(book: Book) {
if (book.isLocal) {
execute {
LocalBook.getChapterList(book).let {
@@ -156,8 +156,6 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
ReadBook.upMsg("LoadTocError:${it.localizedMessage}")
}
}
- }.onFinally {
- callback?.invoke()
}
} else {
ReadBook.bookSource?.let {
@@ -177,8 +175,6 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
ReadBook.loadContent(resetPageOffset = true)
}.onError {
ReadBook.upMsg(context.getString(R.string.error_load_toc))
- }.onFinally {
- callback?.invoke()
}
}
}