mirror of
https://github.com/gedoor/legado.git
synced 2024-09-03 09:48:16 +08:00
Merge pull request #1863 from Xwite/master
feat: add prompt when open local book
This commit is contained in:
commit
794a11a4d3
@ -4,13 +4,16 @@ import android.app.Application
|
||||
import android.net.Uri
|
||||
import androidx.documentfile.provider.DocumentFile
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import io.legado.app.R
|
||||
import io.legado.app.constant.AppPattern.bookFileRegex
|
||||
import io.legado.app.exception.NoStackTraceException
|
||||
import io.legado.app.lib.dialogs.alert
|
||||
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
|
||||
import splitties.init.appCtx
|
||||
|
||||
class FileAssociationViewModel(application: Application) : BaseAssociationViewModel(application) {
|
||||
val importBookLiveData = MutableLiveData<Uri>()
|
||||
@ -53,14 +56,19 @@ class FileAssociationViewModel(application: Application) : BaseAssociationViewMo
|
||||
importTextTocRule(content, finally)
|
||||
content.contains("name") && content.contains("url") ->
|
||||
importHttpTTS(content, finally)
|
||||
else -> errorLiveData.postValue("格式不对")
|
||||
else -> errorLiveData.postValue(appCtx.getString(R.string.wrong_format))
|
||||
}
|
||||
}
|
||||
fileName.matches(bookFileRegex) -> {
|
||||
importBookLiveData.postValue(uri)
|
||||
!fileName.matches(bookFileRegex) -> {
|
||||
appCtx.alert(title = appCtx.getString(R.string.draw), message = appCtx.getString(R.string.file_not_supported, fileName)) {
|
||||
okButton {
|
||||
importBookLiveData.postValue(uri)
|
||||
}
|
||||
cancelButton()
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
throw NoStackTraceException("$fileName 暂未支持的本地书籍格式(TXT/UMD/EPUB)")
|
||||
importBookLiveData.postValue(uri)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -974,5 +974,6 @@
|
||||
<string name="input_verification_code">输入验证码</string>
|
||||
<string name="verification_code">验证码</string>
|
||||
<string name="timeout_millisecond">超时毫秒数</string>
|
||||
<string name="file_not_supported">Continue to open although %1$s is not supported ?</string>
|
||||
<!-- string end -->
|
||||
</resources>
|
||||
|
@ -977,5 +977,6 @@
|
||||
<string name="input_verification_code">输入验证码</string>
|
||||
<string name="verification_code">验证码</string>
|
||||
<string name="timeout_millisecond">超时毫秒数</string>
|
||||
<string name="file_not_supported">Continue to open although %1$s is not supported ?</string>
|
||||
<!-- string end -->
|
||||
</resources>
|
||||
|
@ -977,5 +977,6 @@
|
||||
<string name="input_verification_code">输入验证码</string>
|
||||
<string name="verification_code">验证码</string>
|
||||
<string name="timeout_millisecond">超时毫秒数</string>
|
||||
<string name="file_not_supported">Continue to open although %1$s is not supported ?</string>
|
||||
<!-- string end -->
|
||||
</resources>
|
||||
|
@ -974,5 +974,6 @@
|
||||
<string name="input_verification_code">输入验证码</string>
|
||||
<string name="verification_code">验证码</string>
|
||||
<string name="timeout_millisecond">超时毫秒数</string>
|
||||
<string name="file_not_supported">文件%1$s 不受支持,是否继续打开?</string>
|
||||
<!-- string end -->
|
||||
</resources>
|
||||
|
@ -976,5 +976,6 @@
|
||||
<string name="input_verification_code">输入验证码</string>
|
||||
<string name="verification_code">验证码</string>
|
||||
<string name="timeout_millisecond">超时毫秒数</string>
|
||||
<string name="file_not_supported">文件%1$s 不受支持,是否继续打开?</string>
|
||||
<!-- string end -->
|
||||
</resources>
|
||||
|
@ -976,5 +976,6 @@
|
||||
<string name="input_verification_code">输入验证码</string>
|
||||
<string name="verification_code">验证码</string>
|
||||
<string name="timeout_millisecond">超时毫秒数</string>
|
||||
<string name="file_not_supported">文件%1$s 不受支持,是否继续打开?</string>
|
||||
<!-- string end -->
|
||||
</resources>
|
||||
|
@ -977,7 +977,6 @@
|
||||
<string name="input_verification_code">输入验证码</string>
|
||||
<string name="verification_code">验证码</string>
|
||||
<string name="timeout_millisecond">超时毫秒数</string>
|
||||
|
||||
|
||||
<string name="file_not_supported">Continue to open although %1$s is not supported ?</string>
|
||||
<!-- string end -->
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user