优化
This commit is contained in:
@@ -356,6 +356,8 @@
|
|||||||
<data android:mimeType="application/json" />
|
<data android:mimeType="application/json" />
|
||||||
<!-- EPUB -->
|
<!-- EPUB -->
|
||||||
<data android:mimeType="application/epub+zip" />
|
<data android:mimeType="application/epub+zip" />
|
||||||
|
<!-- pdf -->
|
||||||
|
<data android:mimeType="application/pdf" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
<!-- Works when an app doesn't know the media type, e.g. Dropbox -->
|
<!-- Works when an app doesn't know the media type, e.g. Dropbox -->
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
@@ -372,14 +374,13 @@
|
|||||||
<!-- This media type is necessary, otherwise it won't match on the file extension -->
|
<!-- This media type is necessary, otherwise it won't match on the file extension -->
|
||||||
<data android:mimeType="*/*" />
|
<data android:mimeType="*/*" />
|
||||||
<!--TXT-->
|
<!--TXT-->
|
||||||
<data android:pathPattern=".*\\.txt" />
|
<data android:pathAdvancedPattern=".*\\.[tT][xX][tT]" />
|
||||||
<data android:pathPattern=".*\\.TXT" />
|
|
||||||
<!--JSON-->
|
<!--JSON-->
|
||||||
<data android:pathPattern=".*\\.json" />
|
<data android:pathAdvancedPattern=".*\\.[jJ][sS][oO][nN]" />
|
||||||
<data android:pathPattern=".*\\.JSON" />
|
|
||||||
<!-- EPUB -->
|
<!-- EPUB -->
|
||||||
<data android:pathPattern=".*\\.epub" />
|
<data android:pathAdvancedPattern=".*\\.[eE][pP][uU][bB]" />
|
||||||
<data android:pathPattern=".*\\.EPUB" />
|
<!-- pdf -->
|
||||||
|
<data android:pathAdvancedPattern=".*\\.[pP][dD][fF]" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
|
|||||||
@@ -501,7 +501,7 @@ object ReadBook : CoroutineScope by MainScope() {
|
|||||||
interface CallBack {
|
interface CallBack {
|
||||||
fun upMenuView()
|
fun upMenuView()
|
||||||
|
|
||||||
fun loadChapterList(book: Book, callback: (() -> Unit)? = null)
|
fun loadChapterList(book: Book)
|
||||||
|
|
||||||
fun upContent(
|
fun upContent(
|
||||||
relativePosition: Int = 0,
|
relativePosition: Int = 0,
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ object LocalBook {
|
|||||||
val bookUrl: String
|
val bookUrl: String
|
||||||
val updateTime: Long
|
val updateTime: Long
|
||||||
//这个变量不要修改,否则会导致读取不到缓存
|
//这个变量不要修改,否则会导致读取不到缓存
|
||||||
val fileName = (if (uri.isContentScheme()) {
|
val fileName = if (uri.isContentScheme()) {
|
||||||
bookUrl = uri.toString()
|
bookUrl = uri.toString()
|
||||||
val doc = DocumentFile.fromSingleUri(appCtx, uri)!!
|
val doc = DocumentFile.fromSingleUri(appCtx, uri)!!
|
||||||
updateTime = doc.lastModified()
|
updateTime = doc.lastModified()
|
||||||
@@ -164,7 +164,7 @@ object LocalBook {
|
|||||||
val file = File(bookUrl)
|
val file = File(bookUrl)
|
||||||
updateTime = file.lastModified()
|
updateTime = file.lastModified()
|
||||||
file.name
|
file.name
|
||||||
})
|
}
|
||||||
var book = appDb.bookDao.getBook(bookUrl)
|
var book = appDb.bookDao.getBook(bookUrl)
|
||||||
if (book == null) {
|
if (book == null) {
|
||||||
val nameAuthor = analyzeNameAuthor(fileName)
|
val nameAuthor = analyzeNameAuthor(fileName)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package io.legado.app.ui.association
|
package io.legado.app.ui.association
|
||||||
|
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.activity.viewModels
|
import androidx.activity.viewModels
|
||||||
import androidx.documentfile.provider.DocumentFile
|
import androidx.documentfile.provider.DocumentFile
|
||||||
@@ -104,7 +105,9 @@ class FileAssociationActivity :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
intent.data?.let { data ->
|
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)
|
PermissionsCompat.Builder(this)
|
||||||
.addPermissions(*Permissions.Group.STORAGE)
|
.addPermissions(*Permissions.Group.STORAGE)
|
||||||
.rationale(R.string.tip_perm_request_storage)
|
.rationale(R.string.tip_perm_request_storage)
|
||||||
@@ -112,7 +115,7 @@ class FileAssociationActivity :
|
|||||||
viewModel.dispatchIndent(data)
|
viewModel.dispatchIndent(data)
|
||||||
}.request()
|
}.request()
|
||||||
} else {
|
} 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))
|
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) {
|
if (book.isLocal) {
|
||||||
execute {
|
execute {
|
||||||
LocalBook.getChapterList(book).let {
|
LocalBook.getChapterList(book).let {
|
||||||
@@ -156,8 +156,6 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
|
|||||||
ReadBook.upMsg("LoadTocError:${it.localizedMessage}")
|
ReadBook.upMsg("LoadTocError:${it.localizedMessage}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.onFinally {
|
|
||||||
callback?.invoke()
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ReadBook.bookSource?.let {
|
ReadBook.bookSource?.let {
|
||||||
@@ -177,8 +175,6 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
|
|||||||
ReadBook.loadContent(resetPageOffset = true)
|
ReadBook.loadContent(resetPageOffset = true)
|
||||||
}.onError {
|
}.onError {
|
||||||
ReadBook.upMsg(context.getString(R.string.error_load_toc))
|
ReadBook.upMsg(context.getString(R.string.error_load_toc))
|
||||||
}.onFinally {
|
|
||||||
callback?.invoke()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user