diff --git a/app/src/main/java/io/legado/app/ui/association/FileAssociationViewModel.kt b/app/src/main/java/io/legado/app/ui/association/FileAssociationViewModel.kt index 9a328c603..65ec277ed 100644 --- a/app/src/main/java/io/legado/app/ui/association/FileAssociationViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/association/FileAssociationViewModel.kt @@ -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() @@ -37,11 +40,16 @@ class FileAssociationViewModel(application: Application) : BaseAssociationViewMo content.isJson() -> { importJson(content) } - 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 { diff --git a/app/src/main/res/values-es-rES/strings.xml b/app/src/main/res/values-es-rES/strings.xml index 1c1ebb484..fe5df6c92 100644 --- a/app/src/main/res/values-es-rES/strings.xml +++ b/app/src/main/res/values-es-rES/strings.xml @@ -974,5 +974,6 @@ 输入验证码 验证码 超时毫秒数 + Continue to open although %1$s is not supported ? diff --git a/app/src/main/res/values-ja-rJP/strings.xml b/app/src/main/res/values-ja-rJP/strings.xml index 02b599a14..353d069d9 100644 --- a/app/src/main/res/values-ja-rJP/strings.xml +++ b/app/src/main/res/values-ja-rJP/strings.xml @@ -977,5 +977,6 @@ 输入验证码 验证码 超时毫秒数 + Continue to open although %1$s is not supported ? diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index faba804f0..a48c48550 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -977,5 +977,6 @@ 输入验证码 验证码 超时毫秒数 + Continue to open although %1$s is not supported ? diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index c9262f925..7fc0a122c 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -974,5 +974,6 @@ 输入验证码 验证码 超时毫秒数 + 文件%1$s 不受支持,是否继续打开? diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 0334fd0ab..e3268bd18 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -976,5 +976,6 @@ 输入验证码 验证码 超时毫秒数 + 文件%1$s 不受支持,是否继续打开? diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index f522e28bc..5e9a4d0c0 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -976,5 +976,6 @@ 输入验证码 验证码 超时毫秒数 + 文件%1$s 不受支持,是否继续打开? diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4468bf740..d1b76d892 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -977,7 +977,6 @@ 输入验证码 验证码 超时毫秒数 - - + Continue to open although %1$s is not supported ?