Merge pull request #391 from 10bits/master

优化webdav备份离线缓存书籍
pull/394/head
kunfei 4 years ago committed by GitHub
commit 44f1edb7c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      app/src/main/java/io/legado/app/constant/PreferKey.kt
  2. 7
      app/src/main/java/io/legado/app/ui/book/cache/CacheViewModel.kt
  3. 4
      app/src/main/res/values-zh-rHK/strings.xml
  4. 4
      app/src/main/res/values-zh-rTW/strings.xml
  5. 4
      app/src/main/res/values-zh/strings.xml
  6. 4
      app/src/main/res/values/strings.xml
  7. 4
      app/src/main/res/xml/pref_config_backup.xml

@ -33,7 +33,7 @@ object PreferKey {
const val webDavAccount = "web_dav_account" const val webDavAccount = "web_dav_account"
const val webDavPassword = "web_dav_password" const val webDavPassword = "web_dav_password"
const val webDavCreateDir = "webDavCreateDir" const val webDavCreateDir = "webDavCreateDir"
const val webDavExport = "webDavExport" const val webDavCacheBackup = "webDavCacheBackup"
const val changeSourceLoadToc = "changeSourceLoadToc" const val changeSourceLoadToc = "changeSourceLoadToc"
const val chineseConverterType = "chineseConverterType" const val chineseConverterType = "chineseConverterType"
const val launcherIcon = "launcherIcon" const val launcherIcon = "launcherIcon"

@ -40,12 +40,11 @@ class CacheViewModel(application: Application) : BaseViewModel(application) {
val content = getAllContents(book) val content = getAllContents(book)
DocumentUtils.createFileIfNotExist(doc, filename) DocumentUtils.createFileIfNotExist(doc, filename)
?.writeText(context, content) ?.writeText(context, content)
if(App.INSTANCE.getPrefBoolean(PreferKey.webDavExport,false)) { if(App.INSTANCE.getPrefBoolean(PreferKey.webDavCacheBackup,false)) {
//写出文件到cache目录
FileUtils.createFileIfNotExist( FileUtils.createFileIfNotExist(
File(FileUtils.getCachePath()), File(FileUtils.getCachePath()),
filename filename
).writeText(content) ).writeText(content) // 写出文件到cache目录
// 导出到webdav // 导出到webdav
WebDavHelp.exportWebDav(FileUtils.getCachePath(), filename) WebDavHelp.exportWebDav(FileUtils.getCachePath(), filename)
// 上传完删除cache文件 // 上传完删除cache文件
@ -79,7 +78,7 @@ class CacheViewModel(application: Application) : BaseViewModel(application) {
val filename = "${book.name} by ${book.author}.txt" val filename = "${book.name} by ${book.author}.txt"
FileUtils.createFileIfNotExist(file, filename) FileUtils.createFileIfNotExist(file, filename)
.writeText(getAllContents(book)) .writeText(getAllContents(book))
if(App.INSTANCE.getPrefBoolean(PreferKey.webDavExport,false)) { if(App.INSTANCE.getPrefBoolean(PreferKey.webDavCacheBackup,false)) {
WebDavHelp.exportWebDav(file.absolutePath, filename) // 导出到webdav WebDavHelp.exportWebDav(file.absolutePath, filename) // 导出到webdav
} }
App.db.bookChapterDao().getChapterList(book.bookUrl).forEach { chapter -> App.db.bookChapterDao().getChapterList(book.bookUrl).forEach { chapter ->

@ -10,8 +10,8 @@
<string name="menu_import_old">導入閲讀數據</string> <string name="menu_import_old">導入閲讀數據</string>
<string name="mkdirs">創建子文件夾</string> <string name="mkdirs">創建子文件夾</string>
<string name="mkdirs_description">創建 legado 文件夾作爲備份路徑</string> <string name="mkdirs_description">創建 legado 文件夾作爲備份路徑</string>
<string name="export_webdav">離線導出WebDav</string> <string name="webdav_cache_backup">離線緩存書籍備份</string>
<string name="export_webdav_s">默認導出到legado文件夾下exports目錄</string> <string name="webdav_cache_backup_s">導出本地同時備份到legado文件夾下exports目錄</string>
<string name="backup_path">備份路徑</string> <string name="backup_path">備份路徑</string>
<string name="menu_import_old_version">導入舊版數據</string> <string name="menu_import_old_version">導入舊版數據</string>
<string name="menu_import_github">導入 Github 數據</string> <string name="menu_import_github">導入 Github 數據</string>

@ -10,8 +10,8 @@
<string name="menu_import_old">匯入閱讀資料</string> <string name="menu_import_old">匯入閱讀資料</string>
<string name="mkdirs">建立子資料夾</string> <string name="mkdirs">建立子資料夾</string>
<string name="mkdirs_description">建立legado資料夾作為備份資料夾</string> <string name="mkdirs_description">建立legado資料夾作為備份資料夾</string>
<string name="export_webdav">離線導出WebDav</string> <string name="webdav_cache_backup">離線緩存書籍備份</string>
<string name="export_webdav_s">默認導出到legado文件夾下exports目錄</string> <string name="webdav_cache_backup_s">導出本地同時備份到legado文件夾下exports目錄</string>
<string name="backup_path">備份路徑</string> <string name="backup_path">備份路徑</string>
<string name="menu_import_old_version">匯入舊版資料</string> <string name="menu_import_old_version">匯入舊版資料</string>
<string name="menu_import_github">匯入Github資料</string> <string name="menu_import_github">匯入Github資料</string>

@ -10,8 +10,8 @@
<string name="menu_import_old">导入阅读数据</string> <string name="menu_import_old">导入阅读数据</string>
<string name="mkdirs">创建子文件夹</string> <string name="mkdirs">创建子文件夹</string>
<string name="mkdirs_description">创建legado文件夹作为备份文件夹</string> <string name="mkdirs_description">创建legado文件夹作为备份文件夹</string>
<string name="export_webdav">离线导出WebDav</string> <string name="webdav_cache_backup">离线缓存书籍备份</string>
<string name="export_webdav_s">默认导出到legado文件夹下exports目录</string> <string name="webdav_cache_backup_s">导出本地同时备份到legado文件夹下exports目录</string>
<string name="backup_path">备份路径</string> <string name="backup_path">备份路径</string>
<string name="select_backup_path">请选择备份路径</string> <string name="select_backup_path">请选择备份路径</string>
<string name="menu_import_old_version">导入旧版数据</string> <string name="menu_import_old_version">导入旧版数据</string>

@ -10,8 +10,8 @@
<string name="menu_import_old">Import Legado data</string> <string name="menu_import_old">Import Legado data</string>
<string name="mkdirs">Create a subfolder</string> <string name="mkdirs">Create a subfolder</string>
<string name="mkdirs_description">Create a folder named Legado as the backup folder.</string> <string name="mkdirs_description">Create a folder named Legado as the backup folder.</string>
<string name="export_webdav">Export Webdav</string> <string name="webdav_cache_backup">Offline cache book backup</string>
<string name="export_webdav_s">Default export to the exports directory under the legado folder</string> <string name="webdav_cache_backup_s">Export to local and back up to the exports directory under the legado folder</string>
<string name="backup_path">Backup to</string> <string name="backup_path">Backup to</string>
<string name="select_backup_path">Please select a backup path.</string> <string name="select_backup_path">Please select a backup path.</string>
<string name="menu_import_old_version">Import legacy data</string> <string name="menu_import_old_version">Import legacy data</string>

@ -39,8 +39,8 @@
<io.legado.app.ui.widget.prefs.SwitchPreference <io.legado.app.ui.widget.prefs.SwitchPreference
android:key="webDavExport" android:key="webDavExport"
android:defaultValue="false" android:defaultValue="false"
android:title="@string/export_webdav" android:title="@string/webdav_cache_backup"
android:summary="@string/export_webdav_s" android:summary="@string/webdav_cache_backup_s"
app:allowDividerAbove="false" app:allowDividerAbove="false"
app:allowDividerBelow="false" app:allowDividerBelow="false"
app:iconSpaceReserved="false" /> app:iconSpaceReserved="false" />

Loading…
Cancel
Save