diff --git a/app/src/main/java/io/legado/app/ui/config/BackupConfigFragment.kt b/app/src/main/java/io/legado/app/ui/config/BackupConfigFragment.kt index e684ccfff..85740f674 100644 --- a/app/src/main/java/io/legado/app/ui/config/BackupConfigFragment.kt +++ b/app/src/main/java/io/legado/app/ui/config/BackupConfigFragment.kt @@ -46,6 +46,8 @@ class BackupConfigFragment : PreferenceFragmentCompat(), upPreferenceSummary(PreferKey.webDavAccount, getPrefString(PreferKey.webDavAccount)) upPreferenceSummary(PreferKey.webDavPassword, getPrefString(PreferKey.webDavPassword)) upPreferenceSummary(PreferKey.backupPath, getPrefString(PreferKey.backupPath)) + findPreference("web_dav_restore") + ?.onLongClick = { BackupRestoreUi.restoreByFolder(this) } } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { @@ -114,6 +116,7 @@ class BackupConfigFragment : PreferenceFragmentCompat(), return super.onPreferenceTreeClick(preference) } + private fun restoreIgnore() { val checkedItems = BooleanArray(Restore.ignoreKeys.size) { Restore.ignoreConfig[Restore.ignoreKeys[it]] ?: false diff --git a/app/src/main/java/io/legado/app/ui/config/BackupRestoreUi.kt b/app/src/main/java/io/legado/app/ui/config/BackupRestoreUi.kt index 67e59d521..b99ef4d8d 100644 --- a/app/src/main/java/io/legado/app/ui/config/BackupRestoreUi.kt +++ b/app/src/main/java/io/legado/app/ui/config/BackupRestoreUi.kt @@ -100,6 +100,10 @@ object BackupRestoreUi { } } + fun restoreByFolder(fragment: Fragment) { + selectBackupFolder(fragment, restoreSelectRequestCode) + } + private fun restoreUsePermission(fragment: Fragment, path: String) { PermissionsCompat.Builder(fragment) .addPermissions(*Permissions.Group.STORAGE) diff --git a/app/src/main/java/io/legado/app/ui/widget/prefs/Preference.kt b/app/src/main/java/io/legado/app/ui/widget/prefs/Preference.kt index f16799d0e..0e23d21d2 100644 --- a/app/src/main/java/io/legado/app/ui/widget/prefs/Preference.kt +++ b/app/src/main/java/io/legado/app/ui/widget/prefs/Preference.kt @@ -14,11 +14,14 @@ import androidx.preference.PreferenceViewHolder import io.legado.app.R import io.legado.app.lib.theme.accentColor import org.jetbrains.anko.layoutInflater +import org.jetbrains.anko.sdk27.listeners.onLongClick import kotlin.math.roundToInt class Preference(context: Context, attrs: AttributeSet) : androidx.preference.Preference(context, attrs) { + var onLongClick: (() -> Unit)? = null + init { // isPersistent = true layoutResource = R.layout.view_preference @@ -97,6 +100,10 @@ class Preference(context: Context, attrs: AttributeSet) : override fun onBindViewHolder(holder: PreferenceViewHolder?) { bindView(context, holder, icon, title, summary, null, null) super.onBindViewHolder(holder) + holder?.itemView?.onLongClick { + onLongClick?.invoke() + true + } } } diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index 1ebe0fe81..aee400440 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -702,7 +702,7 @@ 其它 legado-top 本地和WebDav壹起備份 - 優先從WebDav恢復,失敗時從本地恢復 + 優先從WebDav恢復,長按從本地恢復 選擇舊版備份文件夾 已啓用 已禁用 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index a600cb802..2c2ef5c0a 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -702,7 +702,7 @@ 文章字體轉換 請選擇備份路徑 本地和WebDav壹起備份 - 優先從WebDav恢復,失敗時從本地恢復 + 優先從WebDav恢復,長按從本地恢復 選擇舊版備份文件夾 已啓用 已禁用 diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index 9a45c4903..2c3ab874a 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -703,7 +703,7 @@ 自动翻页速度 地址排序 本地和WebDav一起备份 - 优先从WebDav恢复,失败时从本地恢复 + 优先从WebDav恢复,长按从本地恢复 选择旧版备份文件夹 已启用 已禁用 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 810277b59..0a475110f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -705,7 +705,7 @@ Auto scroll speed Sort by URL Backup the local and WebDav simultaneously - Restore from WebDAV first, and Restore form the local backup if failed + Restore from WebDAV first, Restore form the local backup on long click Select a legacy backup folder Enabled Disabled