添加自定义webDav文件夹

pull/1592/head
kunfei 3 years ago
parent b97430f93a
commit 93ec50824c
  1. 2
      app/src/main/java/io/legado/app/constant/PreferKey.kt
  2. 2
      app/src/main/java/io/legado/app/help/AppConfig.kt
  3. 12
      app/src/main/java/io/legado/app/help/storage/AppWebDav.kt
  4. 7
      app/src/main/java/io/legado/app/ui/config/BackupConfigFragment.kt
  5. 3
      app/src/main/res/values-es-rES/strings.xml
  6. 3
      app/src/main/res/values-ja-rJP/strings.xml
  7. 3
      app/src/main/res/values-pt-rBR/strings.xml
  8. 3
      app/src/main/res/values-zh-rHK/strings.xml
  9. 3
      app/src/main/res/values-zh-rTW/strings.xml
  10. 3
      app/src/main/res/values-zh/strings.xml
  11. 3
      app/src/main/res/values/strings.xml
  12. 8
      app/src/main/res/xml/pref_config_backup.xml

@ -49,7 +49,7 @@ object PreferKey {
const val webDavUrl = "web_dav_url"
const val webDavAccount = "web_dav_account"
const val webDavPassword = "web_dav_password"
const val webDavCreateDir = "webDavCreateDir"
const val webDavDir = "webDavDir"
const val exportToWebDav = "webDavCacheBackup"
const val exportNoChapterName = "exportNoChapterName"
const val exportType = "exportType"

@ -271,6 +271,8 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener {
val replaceEnableDefault get() = appCtx.getPrefBoolean(PreferKey.replaceEnableDefault, true)
val webDavDir get() = appCtx.getPrefString(PreferKey.webDavDir, "legado")
val recordLog get() = appCtx.getPrefBoolean(PreferKey.recordLog)
val doublePageHorizontal: Boolean

@ -29,13 +29,13 @@ object AppWebDav {
private val rootWebDavUrl: String
get() {
var url = appCtx.getPrefString(PreferKey.webDavUrl)?.trim()
if (url.isNullOrEmpty()) {
url = defaultWebDavUrl
}
val configUrl = appCtx.getPrefString(PreferKey.webDavUrl)?.trim()
var url = if (configUrl.isNullOrEmpty()) defaultWebDavUrl else configUrl
if (!url.endsWith("/")) url = "${url}/"
if (appCtx.getPrefBoolean(PreferKey.webDavCreateDir, true)) {
url = "${url}legado/"
AppConfig.webDavDir?.trim()?.let {
if (it.isNotEmpty()) {
url = "${url}${it}/"
}
}
return url
}

@ -121,6 +121,7 @@ class BackupConfigFragment : BasePreferenceFragment(),
upPreferenceSummary(PreferKey.webDavUrl, getPrefString(PreferKey.webDavUrl))
upPreferenceSummary(PreferKey.webDavAccount, getPrefString(PreferKey.webDavAccount))
upPreferenceSummary(PreferKey.webDavPassword, getPrefString(PreferKey.webDavPassword))
upPreferenceSummary(PreferKey.webDavDir, AppConfig.webDavDir)
upPreferenceSummary(PreferKey.backupPath, getPrefString(PreferKey.backupPath))
findPreference<io.legado.app.ui.widget.prefs.Preference>("web_dav_restore")
?.onLongClick { restoreDir.launch(); true }
@ -168,6 +169,7 @@ class BackupConfigFragment : BasePreferenceFragment(),
PreferKey.backupPath -> {
upPreferenceSummary(key, getPrefString(key))
}
PreferKey.webDavDir -> upPreferenceSummary(key, AppConfig.webDavDir)
}
}
@ -192,6 +194,11 @@ class BackupConfigFragment : BasePreferenceFragment(),
} else {
preference.summary = "*".repeat(value.toString().length)
}
PreferKey.webDavDir -> if (value.isNullOrBlank()) {
preference.summary = "null"
} else {
preference.summary = value
}
else -> {
if (preference is ListPreference) {
val index = preference.findIndexOfValue(value)

@ -9,8 +9,6 @@
<string name="menu_backup">Inicio</string>
<string name="menu_restore">Restaurar</string>
<string name="menu_import_old">Importar datos de Legado</string>
<string name="mkdirs">Crear carpeta</string>
<string name="mkdirs_description">Crea una carpeta de respaldo bajo el nombre de Legado.</string>
<string name="webdav_cache_backup">Respaldo de caché de libros sin conexión</string>
<string name="webdav_cache_backup_s">Exporta localmente lo respalda para su exportación</string>
<string name="backup_path">Respaldar para</string>
@ -927,5 +925,6 @@
<string name="less_than">小于</string>
<string name="check_source_config_summary">校验超时: %1$s秒\n校验项目:%2$s</string>
<string name="record_debug_log">记录调试日志</string>
<string name="sub_dir">子文件夹</string>
<!-- string end -->
</resources>

@ -9,8 +9,6 @@
<string name="menu_backup">Home</string>
<string name="menu_restore">Restore</string>
<string name="menu_import_old">Import Legado data</string>
<string name="mkdirs">Create a subfolder</string>
<string name="mkdirs_description">Create a folder named Legado as the backup folder.</string>
<string name="webdav_cache_backup">Offline cache book backup</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>
@ -930,5 +928,6 @@
<string name="less_than">小于</string>
<string name="check_source_config_summary">校验超时: %1$s秒\n校验项目:%2$s</string>
<string name="record_debug_log">记录调试日志</string>
<string name="sub_dir">子文件夹</string>
<!-- string end -->
</resources>

@ -9,8 +9,6 @@
<string name="menu_backup">Início</string>
<string name="menu_restore">Restaurar</string>
<string name="menu_import_old">Importar dados ao Legado</string>
<string name="mkdirs">Criar uma subpasta</string>
<string name="mkdirs_description">Criar uma pasta de Backup com o nome Legado.</string>
<string name="webdav_cache_backup">Backup do cache dos livros para leitura off-line</string>
<string name="webdav_cache_backup_s">Exportar localmente e fazer Backup à pasta de exportação</string>
<string name="backup_path">Backup para</string>
@ -930,5 +928,6 @@
<string name="less_than">小于</string>
<string name="check_source_config_summary">校验超时: %1$s秒\n校验项目:%2$s</string>
<string name="record_debug_log">记录调试日志</string>
<string name="sub_dir">子文件夹</string>
<!-- string end -->
</resources>

@ -8,8 +8,6 @@
<string name="menu_backup">Home</string>
<string name="menu_restore">還原</string>
<string name="menu_import_old">導入閲讀數據</string>
<string name="mkdirs">創建子文件夾</string>
<string name="mkdirs_description">創建 legado 文件夾作爲備份路徑</string>
<string name="webdav_cache_backup">離線緩存書籍備份</string>
<string name="webdav_cache_backup_s">導出本地同時備份到legado文件夾下exports目錄</string>
<string name="backup_path">備份路徑</string>
@ -927,5 +925,6 @@
<string name="less_than">小于</string>
<string name="check_source_config_summary">校验超时: %1$s秒\n校验项目:%2$s</string>
<string name="record_debug_log">记录调试日志</string>
<string name="sub_dir">子文件夹</string>
<!-- string end -->
</resources>

@ -8,8 +8,6 @@
<string name="menu_backup">備份</string>
<string name="menu_restore">復原</string>
<string name="menu_import_old">匯入閱讀資料</string>
<string name="mkdirs">建立子資料夾</string>
<string name="mkdirs_description">建立legado資料夾作為備份資料夾</string>
<string name="webdav_cache_backup">離線快取書籍備份</string>
<string name="webdav_cache_backup_s">匯出本機同時備份到legado資料夾下exports目錄</string>
<string name="backup_path">備份路徑</string>
@ -929,5 +927,6 @@
<string name="less_than">小于</string>
<string name="check_source_config_summary">校验超时: %1$s秒\n校验项目:%2$s</string>
<string name="record_debug_log">记录调试日志</string>
<string name="sub_dir">子文件夹</string>
<!-- string end -->
</resources>

@ -8,8 +8,6 @@
<string name="menu_backup">Home</string>
<string name="menu_restore">恢复</string>
<string name="menu_import_old">导入阅读数据</string>
<string name="mkdirs">创建子文件夹</string>
<string name="mkdirs_description">创建legado文件夹作为备份文件夹</string>
<string name="webdav_cache_backup">离线缓存书籍备份</string>
<string name="webdav_cache_backup_s">导出本地同时备份到legado文件夹下exports目录</string>
<string name="backup_path">备份路径</string>
@ -929,5 +927,6 @@
<string name="less_than">小于</string>
<string name="check_source_config_summary">校验超时: %1$s秒\n校验项目:%2$s</string>
<string name="record_debug_log">记录调试日志</string>
<string name="sub_dir">子文件夹</string>
<!-- string end -->
</resources>

@ -9,8 +9,6 @@
<string name="menu_backup">Home</string>
<string name="menu_restore">Restore</string>
<string name="menu_import_old">Import Legado data</string>
<string name="mkdirs">Create a subfolder</string>
<string name="mkdirs_description">Create a folder named Legado as the backup folder.</string>
<string name="webdav_cache_backup">Offline cache book backup</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>
@ -930,5 +928,6 @@
<string name="less_than">小于</string>
<string name="check_source_config_summary">校验超时: %1$s秒\n校验项目:%2$s</string>
<string name="record_debug_log">记录调试日志</string>
<string name="sub_dir">Sub dir</string>
<!-- string end -->
</resources>

@ -27,11 +27,9 @@
android:summary="@string/web_dav_pw_s"
app:iconSpaceReserved="false" />
<io.legado.app.ui.widget.prefs.SwitchPreference
android:key="webDavCreateDir"
android:defaultValue="true"
android:title="@string/mkdirs"
android:summary="@string/mkdirs_description"
<io.legado.app.ui.widget.prefs.EditTextPreference
android:key="webDavDir"
android:title="@string/sub_dir"
app:allowDividerAbove="false"
app:allowDividerBelow="false"
app:iconSpaceReserved="false" />

Loading…
Cancel
Save