pull/2718/head
Horis 2 years ago
parent 82afa372d9
commit 1172c35076
  1. 13
      app/src/main/AndroidManifest.xml
  2. 2
      app/src/main/java/io/legado/app/model/ReadBook.kt
  3. 4
      app/src/main/java/io/legado/app/model/localBook/LocalBook.kt
  4. 7
      app/src/main/java/io/legado/app/ui/association/FileAssociationActivity.kt
  5. 4
      app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt
  6. 6
      app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt

@ -356,6 +356,8 @@
<data android:mimeType="application/json" />
<!-- EPUB -->
<data android:mimeType="application/epub+zip" />
<!-- pdf -->
<data android:mimeType="application/pdf" />
</intent-filter>
<!-- Works when an app doesn't know the media type, e.g. Dropbox -->
<intent-filter>
@ -372,14 +374,13 @@
<!-- This media type is necessary, otherwise it won't match on the file extension -->
<data android:mimeType="*/*" />
<!--TXT-->
<data android:pathPattern=".*\\.txt" />
<data android:pathPattern=".*\\.TXT" />
<data android:pathAdvancedPattern=".*\\.[tT][xX][tT]" />
<!--JSON-->
<data android:pathPattern=".*\\.json" />
<data android:pathPattern=".*\\.JSON" />
<data android:pathAdvancedPattern=".*\\.[jJ][sS][oO][nN]" />
<!-- EPUB -->
<data android:pathPattern=".*\\.epub" />
<data android:pathPattern=".*\\.EPUB" />
<data android:pathAdvancedPattern=".*\\.[eE][pP][uU][bB]" />
<!-- pdf -->
<data android:pathAdvancedPattern=".*\\.[pP][dD][fF]" />
</intent-filter>
</activity>

@ -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,

@ -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)

@ -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("由于安卓系统限制,请使用系统文件管理重新打开。")
}
}
}

@ -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)
}
/**

@ -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()
}
}
}

Loading…
Cancel
Save