|
|
@ -8,7 +8,7 @@ import io.legado.app.data.entities.BookSource |
|
|
|
import io.legado.app.utils.DocumentUtils |
|
|
|
import io.legado.app.utils.DocumentUtils |
|
|
|
import io.legado.app.utils.FileUtils |
|
|
|
import io.legado.app.utils.FileUtils |
|
|
|
import io.legado.app.utils.isContentScheme |
|
|
|
import io.legado.app.utils.isContentScheme |
|
|
|
import io.legado.app.utils.toastOnUI |
|
|
|
import io.legado.app.utils.toastOnUi |
|
|
|
import java.io.File |
|
|
|
import java.io.File |
|
|
|
|
|
|
|
|
|
|
|
object ImportOldData { |
|
|
|
object ImportOldData { |
|
|
@ -21,28 +21,28 @@ object ImportOldData { |
|
|
|
kotlin.runCatching { |
|
|
|
kotlin.runCatching { |
|
|
|
DocumentUtils.readText(context, doc.uri)?.let { json -> |
|
|
|
DocumentUtils.readText(context, doc.uri)?.let { json -> |
|
|
|
val importCount = importOldBookshelf(json) |
|
|
|
val importCount = importOldBookshelf(json) |
|
|
|
context.toastOnUI("成功导入书籍${importCount}") |
|
|
|
context.toastOnUi("成功导入书籍${importCount}") |
|
|
|
} |
|
|
|
} |
|
|
|
}.onFailure { |
|
|
|
}.onFailure { |
|
|
|
context.toastOnUI("导入书籍失败\n${it.localizedMessage}") |
|
|
|
context.toastOnUi("导入书籍失败\n${it.localizedMessage}") |
|
|
|
} |
|
|
|
} |
|
|
|
"myBookSource.json" -> |
|
|
|
"myBookSource.json" -> |
|
|
|
kotlin.runCatching { |
|
|
|
kotlin.runCatching { |
|
|
|
DocumentUtils.readText(context, doc.uri)?.let { json -> |
|
|
|
DocumentUtils.readText(context, doc.uri)?.let { json -> |
|
|
|
val importCount = importOldSource(json) |
|
|
|
val importCount = importOldSource(json) |
|
|
|
context.toastOnUI("成功导入书源${importCount}") |
|
|
|
context.toastOnUi("成功导入书源${importCount}") |
|
|
|
} |
|
|
|
} |
|
|
|
}.onFailure { |
|
|
|
}.onFailure { |
|
|
|
context.toastOnUI("导入源失败\n${it.localizedMessage}") |
|
|
|
context.toastOnUi("导入源失败\n${it.localizedMessage}") |
|
|
|
} |
|
|
|
} |
|
|
|
"myBookReplaceRule.json" -> |
|
|
|
"myBookReplaceRule.json" -> |
|
|
|
kotlin.runCatching { |
|
|
|
kotlin.runCatching { |
|
|
|
DocumentUtils.readText(context, doc.uri)?.let { json -> |
|
|
|
DocumentUtils.readText(context, doc.uri)?.let { json -> |
|
|
|
val importCount = importOldReplaceRule(json) |
|
|
|
val importCount = importOldReplaceRule(json) |
|
|
|
context.toastOnUI("成功导入替换规则${importCount}") |
|
|
|
context.toastOnUi("成功导入替换规则${importCount}") |
|
|
|
} |
|
|
|
} |
|
|
|
}.onFailure { |
|
|
|
}.onFailure { |
|
|
|
context.toastOnUI("导入替换规则失败\n${it.localizedMessage}") |
|
|
|
context.toastOnUi("导入替换规则失败\n${it.localizedMessage}") |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -54,9 +54,9 @@ object ImportOldData { |
|
|
|
FileUtils.createFileIfNotExist(file, "myBookShelf.json") |
|
|
|
FileUtils.createFileIfNotExist(file, "myBookShelf.json") |
|
|
|
val json = shelfFile.readText() |
|
|
|
val json = shelfFile.readText() |
|
|
|
val importCount = importOldBookshelf(json) |
|
|
|
val importCount = importOldBookshelf(json) |
|
|
|
context.toastOnUI("成功导入书籍${importCount}") |
|
|
|
context.toastOnUi("成功导入书籍${importCount}") |
|
|
|
}.onFailure { |
|
|
|
}.onFailure { |
|
|
|
context.toastOnUI("导入书籍失败\n${it.localizedMessage}") |
|
|
|
context.toastOnUi("导入书籍失败\n${it.localizedMessage}") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
kotlin.runCatching {// Book source |
|
|
|
kotlin.runCatching {// Book source |
|
|
@ -64,9 +64,9 @@ object ImportOldData { |
|
|
|
FileUtils.getFile(file, "myBookSource.json") |
|
|
|
FileUtils.getFile(file, "myBookSource.json") |
|
|
|
val json = sourceFile.readText() |
|
|
|
val json = sourceFile.readText() |
|
|
|
val importCount = importOldSource(json) |
|
|
|
val importCount = importOldSource(json) |
|
|
|
context.toastOnUI("成功导入书源${importCount}") |
|
|
|
context.toastOnUi("成功导入书源${importCount}") |
|
|
|
}.onFailure { |
|
|
|
}.onFailure { |
|
|
|
context.toastOnUI("导入源失败\n${it.localizedMessage}") |
|
|
|
context.toastOnUi("导入源失败\n${it.localizedMessage}") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
kotlin.runCatching {// Replace rules |
|
|
|
kotlin.runCatching {// Replace rules |
|
|
@ -74,12 +74,12 @@ object ImportOldData { |
|
|
|
if (ruleFile.exists()) { |
|
|
|
if (ruleFile.exists()) { |
|
|
|
val json = ruleFile.readText() |
|
|
|
val json = ruleFile.readText() |
|
|
|
val importCount = importOldReplaceRule(json) |
|
|
|
val importCount = importOldReplaceRule(json) |
|
|
|
context.toastOnUI("成功导入替换规则${importCount}") |
|
|
|
context.toastOnUi("成功导入替换规则${importCount}") |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
context.toastOnUI("未找到替换规则") |
|
|
|
context.toastOnUi("未找到替换规则") |
|
|
|
} |
|
|
|
} |
|
|
|
}.onFailure { |
|
|
|
}.onFailure { |
|
|
|
context.toastOnUI("导入替换规则失败\n${it.localizedMessage}") |
|
|
|
context.toastOnUi("导入替换规则失败\n${it.localizedMessage}") |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|