This commit is contained in:
Horis
2025-04-06 18:19:35 +08:00
parent def13a8618
commit 02aaee91b0
3 changed files with 31 additions and 20 deletions
+5
View File
@@ -151,6 +151,11 @@ cn.hutool.core.util.**{*;}
*** putIfAbsent(...); *** putIfAbsent(...);
} }
## ChangeBookSourceDialog initNavigationView
-keepclassmembers class androidx.appcompat.widget.Toolbar {
*** mNavButtonView;
}
## JSOUP ## JSOUP
-keep class org.jsoup.**{*;} -keep class org.jsoup.**{*;}
-keep class **.xpath.**{*;} -keep class **.xpath.**{*;}
@@ -322,12 +322,16 @@ class CacheActivity : VMBaseActivity<ActivityCacheBookBinding, CacheViewModel>()
override fun export(position: Int) { override fun export(position: Int) {
val path = ACache.get().getAsString(exportBookPathKey) val path = ACache.get().getAsString(exportBookPathKey)
if (path.isNullOrEmpty() || !FileDoc.fromDir(path).checkWrite()) { lifecycleScope.launch {
selectExportFolder(position) if (path.isNullOrEmpty() ||
} else if (enableCustomExport()) {// 启用自定义导出 and 导出类型为Epub withContext(IO) { !FileDoc.fromDir(path).checkWrite() }
configExportSection(path, position) ) {
} else { selectExportFolder(position)
startExport(path, position) } else if (enableCustomExport()) {// 启用自定义导出 and 导出类型为Epub
configExportSection(path, position)
} else {
startExport(path, position)
}
} }
} }
@@ -2,7 +2,6 @@ package io.legado.app.ui.config
import android.content.Context import android.content.Context
import android.content.SharedPreferences import android.content.SharedPreferences
import android.net.Uri
import android.os.Bundle import android.os.Bundle
import android.text.InputType import android.text.InputType
import android.view.Menu import android.view.Menu
@@ -10,7 +9,6 @@ import android.view.MenuInflater
import android.view.MenuItem import android.view.MenuItem
import android.view.View import android.view.View
import androidx.core.view.MenuProvider import androidx.core.view.MenuProvider
import androidx.documentfile.provider.DocumentFile
import androidx.fragment.app.activityViewModels import androidx.fragment.app.activityViewModels
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import androidx.preference.EditTextPreference import androidx.preference.EditTextPreference
@@ -37,6 +35,7 @@ import io.legado.app.lib.theme.primaryColor
import io.legado.app.ui.about.AppLogDialog import io.legado.app.ui.about.AppLogDialog
import io.legado.app.ui.file.HandleFileContract import io.legado.app.ui.file.HandleFileContract
import io.legado.app.ui.widget.dialog.WaitDialog import io.legado.app.ui.widget.dialog.WaitDialog
import io.legado.app.utils.FileDoc
import io.legado.app.utils.applyTint import io.legado.app.utils.applyTint
import io.legado.app.utils.checkWrite import io.legado.app.utils.checkWrite
import io.legado.app.utils.getPrefString import io.legado.app.utils.getPrefString
@@ -47,7 +46,7 @@ import io.legado.app.utils.showDialogFragment
import io.legado.app.utils.showHelp import io.legado.app.utils.showHelp
import io.legado.app.utils.toEditable import io.legado.app.utils.toEditable
import io.legado.app.utils.toastOnUi import io.legado.app.utils.toastOnUi
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.Dispatchers.Main import kotlinx.coroutines.Dispatchers.Main
import kotlinx.coroutines.Job import kotlinx.coroutines.Job
import kotlinx.coroutines.ensureActive import kotlinx.coroutines.ensureActive
@@ -193,21 +192,21 @@ class BackupConfigFragment : PreferenceFragment(),
if (value.isNullOrBlank()) { if (value.isNullOrBlank()) {
preference.summary = getString(R.string.web_dav_url_s) preference.summary = getString(R.string.web_dav_url_s)
} else { } else {
preference.summary = value.toString() preference.summary = value
} }
PreferKey.webDavAccount -> PreferKey.webDavAccount ->
if (value.isNullOrBlank()) { if (value.isNullOrBlank()) {
preference.summary = getString(R.string.web_dav_account_s) preference.summary = getString(R.string.web_dav_account_s)
} else { } else {
preference.summary = value.toString() preference.summary = value
} }
PreferKey.webDavPassword -> PreferKey.webDavPassword ->
if (value.isNullOrEmpty()) { if (value.isNullOrEmpty()) {
preference.summary = getString(R.string.web_dav_pw_s) preference.summary = getString(R.string.web_dav_pw_s)
} else { } else {
preference.summary = "*".repeat(value.toString().length) preference.summary = "*".repeat(value.length)
} }
PreferKey.webDavDir -> preference.summary = when (value) { PreferKey.webDavDir -> preference.summary = when (value) {
@@ -262,12 +261,15 @@ class BackupConfigFragment : PreferenceFragment(),
backupDir.launch() backupDir.launch()
} else { } else {
if (backupPath.isContentScheme()) { if (backupPath.isContentScheme()) {
val uri = Uri.parse(backupPath) lifecycleScope.launch {
val doc = DocumentFile.fromTreeUri(requireContext(), uri) val canWrite = withContext(IO) {
if (doc?.checkWrite() == true) { FileDoc.fromDir(backupPath).checkWrite()
backup(backupPath) }
} else { if (canWrite) {
backupDir.launch() backup(backupPath)
} else {
backupDir.launch()
}
} }
} else { } else {
backupUsePermission(backupPath) backupUsePermission(backupPath)
@@ -340,9 +342,9 @@ class BackupConfigFragment : PreferenceFragment(),
} }
private suspend fun showRestoreDialog(context: Context) { private suspend fun showRestoreDialog(context: Context) {
val names = withContext(Dispatchers.IO) { AppWebDav.getBackupNames() } val names = withContext(IO) { AppWebDav.getBackupNames() }
if (AppWebDav.isJianGuoYun && names.size > 700) { if (AppWebDav.isJianGuoYun && names.size > 700) {
context.toastOnUi("由于坚果云限制,部分备份可能未显示") context.toastOnUi("由于坚果云限制列出文件数量,部分备份可能未显示,请及时清理旧备份")
} }
if (names.isNotEmpty()) { if (names.isNotEmpty()) {
coroutineContext.ensureActive() coroutineContext.ensureActive()