Merge remote-tracking branch 'origin/master'

pull/1744/head
kunfei 3 years ago
commit 121ccf4dc7
  1. 3
      app/src/main/java/io/legado/app/constant/AppPattern.kt
  2. 6
      app/src/main/java/io/legado/app/ui/association/FileAssociationViewModel.kt
  3. 3
      app/src/main/java/io/legado/app/ui/book/local/ImportBookViewModel.kt

@ -21,6 +21,9 @@ object AppPattern {
//书源调试信息中的各种符号
val debugMessageSymbolRegex = Regex("[⇒◇┌└≡]")
//本地书籍支持类型
val bookFileRegex = Regex("(?i).*\\.(txt|epub|umd)")
/**
* 所有标点
*/

@ -4,12 +4,12 @@ import android.app.Application
import android.net.Uri
import androidx.documentfile.provider.DocumentFile
import androidx.lifecycle.MutableLiveData
import io.legado.app.constant.AppPattern.bookFileRegex
import io.legado.app.exception.NoStackTraceException
import io.legado.app.model.localBook.LocalBook
import io.legado.app.utils.isJson
import io.legado.app.utils.printOnDebug
import io.legado.app.utils.readText
import java.io.File
class FileAssociationViewModel(application: Application) : BaseAssociationViewModel(application) {
@ -48,8 +48,10 @@ class FileAssociationViewModel(application: Application) : BaseAssociationViewMo
importHttpTTS(content, finally)
else -> errorLiveData.postValue("格式不对")
}
} else {
} else if (uri.toString().matches(bookFileRegex)) {
importBookLiveData.postValue(uri)
} else {
throw NoStackTraceException("暂未支持的本地书籍格式(TXT/UMD/EPUB)")
}
} else {
onLineImportLive.postValue(uri)

@ -4,6 +4,7 @@ import android.app.Application
import android.net.Uri
import androidx.documentfile.provider.DocumentFile
import io.legado.app.base.BaseViewModel
import io.legado.app.constant.AppPattern.bookFileRegex
import io.legado.app.constant.PreferKey
import io.legado.app.model.localBook.LocalBook
import io.legado.app.utils.*
@ -19,9 +20,7 @@ import kotlinx.coroutines.withContext
import java.io.File
import java.util.*
class ImportBookViewModel(application: Application) : BaseViewModel(application) {
private val bookFileRegex = Regex("(?i).*\\.(txt|epub|umd)")
var sort = context.getPrefInt(PreferKey.localBookImportSort)
var dataCallback: DataCallback? = null
var dataFlowStart: (() -> Unit)? = null

Loading…
Cancel
Save