|
|
|
@ -133,9 +133,11 @@ object BookHelp { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fun getContent(book: Book, bookChapter: BookChapter): String? { |
|
|
|
|
if (book.isLocalBook()) { |
|
|
|
|
when { |
|
|
|
|
book.isLocalBook() -> { |
|
|
|
|
return AnalyzeTxtFile.getContent(book, bookChapter) |
|
|
|
|
} else if (downloadUri.isDocumentUri(App.INSTANCE)) { |
|
|
|
|
} |
|
|
|
|
downloadUri.isDocumentUri(App.INSTANCE) -> { |
|
|
|
|
DocumentFile.fromTreeUri(App.INSTANCE, downloadUri)?.let { root -> |
|
|
|
|
return DocumentUtils.getDirDocument( |
|
|
|
|
root, |
|
|
|
@ -143,7 +145,8 @@ object BookHelp { |
|
|
|
|
)?.findFile("${bookChapterName(bookChapter)}.nb") |
|
|
|
|
?.uri?.readText(App.INSTANCE) |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
} |
|
|
|
|
else -> { |
|
|
|
|
val file = FileUtils.getFile( |
|
|
|
|
File(downloadPath), |
|
|
|
|
"${bookChapterName(bookChapter)}.nb", |
|
|
|
@ -153,11 +156,14 @@ object BookHelp { |
|
|
|
|
return file.readText() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return null |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fun delContent(book: Book, bookChapter: BookChapter) { |
|
|
|
|
if (downloadUri.isDocumentUri(App.INSTANCE)) { |
|
|
|
|
when { |
|
|
|
|
book.isLocalBook() -> return |
|
|
|
|
downloadUri.isDocumentUri(App.INSTANCE) -> { |
|
|
|
|
DocumentFile.fromTreeUri(App.INSTANCE, downloadUri)?.let { root -> |
|
|
|
|
DocumentUtils.getDirDocument( |
|
|
|
|
root, |
|
|
|
@ -165,7 +171,8 @@ object BookHelp { |
|
|
|
|
)?.findFile("${bookChapterName(bookChapter)}.nb") |
|
|
|
|
?.delete() |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
} |
|
|
|
|
else -> { |
|
|
|
|
FileUtils.createFileIfNotExist( |
|
|
|
|
File(downloadPath), |
|
|
|
|
"${bookChapterName(bookChapter)}.nb", |
|
|
|
@ -173,6 +180,7 @@ object BookHelp { |
|
|
|
|
).delete() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun formatFolderName(folderName: String): String { |
|
|
|
|
return folderName.replace("[\\\\/:*?\"<>|.]".toRegex(), "") |
|
|
|
|