@@ -7,6 +7,7 @@ import io.legado.app.api.ReturnData
|
||||
import io.legado.app.constant.PreferKey
|
||||
import io.legado.app.data.appDb
|
||||
import io.legado.app.data.entities.Book
|
||||
import io.legado.app.help.AppConfig
|
||||
import io.legado.app.help.BookHelp
|
||||
import io.legado.app.help.CacheManager
|
||||
import io.legado.app.help.ContentProcessor
|
||||
@@ -206,7 +207,9 @@ object BookController {
|
||||
?: return returnData.setErrorMsg("fileName 不能为空")
|
||||
val fileData = parameters["fileData"]?.firstOrNull()
|
||||
?: return returnData.setErrorMsg("fileData 不能为空")
|
||||
val file = FileUtils.createFileIfNotExist(LocalBook.cacheFolder, fileName)
|
||||
if (AppConfig.defaultBookTreeUri == null) return returnData.setErrorMsg("没有设置书籍保存位置!")
|
||||
val bookFolder = FileUtils.createFolderIfNotExist(AppConfig.defaultBookTreeUri!!)
|
||||
val file = FileUtils.createFileIfNotExist(bookFolder, fileName)
|
||||
val fileBytes = Base64.decode(fileData.substringAfter("base64,"), Base64.DEFAULT)
|
||||
file.writeBytes(fileBytes)
|
||||
val nameAuthor = LocalBook.analyzeNameAuthor(fileName)
|
||||
|
||||
@@ -24,11 +24,6 @@ import javax.script.SimpleBindings
|
||||
|
||||
object LocalBook {
|
||||
|
||||
private const val folderName = "bookTxt"
|
||||
val cacheFolder: File by lazy {
|
||||
FileUtils.createFolderIfNotExist(appCtx.externalFiles, folderName)
|
||||
}
|
||||
|
||||
@Throws(FileNotFoundException::class, SecurityException::class)
|
||||
fun getBookInputStream(book: Book): InputStream {
|
||||
val uri = Uri.parse(book.bookUrl)
|
||||
@@ -168,15 +163,6 @@ object LocalBook {
|
||||
|
||||
fun deleteBook(book: Book, deleteOriginal: Boolean) {
|
||||
kotlin.runCatching {
|
||||
if (book.isLocalTxt() || book.isUmd()) {
|
||||
cacheFolder.getFile(book.originName).delete()
|
||||
}
|
||||
if (book.isEpub()) {
|
||||
FileUtils.delete(
|
||||
cacheFolder.getFile(book.getFolderName())
|
||||
)
|
||||
}
|
||||
|
||||
if (deleteOriginal) {
|
||||
if (book.bookUrl.isContentScheme()) {
|
||||
val uri = Uri.parse(book.bookUrl)
|
||||
|
||||
@@ -127,8 +127,10 @@ class BookInfoActivity :
|
||||
viewModel.bookSource != null
|
||||
menu.findItem(R.id.menu_set_book_variable)?.isVisible =
|
||||
viewModel.bookSource != null
|
||||
menu.findItem(R.id.menu_can_update)?.isVisible =
|
||||
viewModel.bookSource != null
|
||||
menu.findItem(R.id.menu_limit_content_length)?.isVisible =
|
||||
viewModel.bookSource == null
|
||||
viewModel.bookData.value?.isLocalTxt() ?: false
|
||||
return super.onMenuOpened(featureId, menu)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user