[优化] 修复 WebDav 书籍的一些问题
This commit is contained in:
@@ -8,7 +8,7 @@ import io.legado.app.exception.NoStackTraceException
|
||||
import io.legado.app.help.AppWebDav
|
||||
import io.legado.app.help.book.getRemoteUrl
|
||||
import io.legado.app.help.book.isLocal
|
||||
import io.legado.app.help.config.AppConfig
|
||||
import io.legado.app.ui.config.importBookConfig.ImportBookConfig
|
||||
import io.legado.app.lib.webdav.Authorization
|
||||
import io.legado.app.model.analyzeRule.AnalyzeUrl
|
||||
import io.legado.app.model.analyzeRule.CustomUrl
|
||||
@@ -32,7 +32,7 @@ class RemoteBookRepository(
|
||||
}
|
||||
}
|
||||
|
||||
val currentServerId = AppConfig.remoteServerId
|
||||
val currentServerId = ImportBookConfig.remoteServerId
|
||||
if (currentServerId != AppConst.DEFAULT_WEBDAV_ID) {
|
||||
appDb.serverDao.get(currentServerId)?.getWebDavConfig()?.let {
|
||||
return RemoteBookWebDav(it.url, Authorization(it), currentServerId)
|
||||
|
||||
@@ -9,12 +9,10 @@ import io.legado.app.ui.book.manga.config.MangaScrollMode
|
||||
import io.legado.app.utils.canvasrecorder.CanvasRecorderFactory
|
||||
import io.legado.app.utils.getPrefBoolean
|
||||
import io.legado.app.utils.getPrefInt
|
||||
import io.legado.app.utils.getPrefLong
|
||||
import io.legado.app.utils.getPrefString
|
||||
import io.legado.app.utils.isNightMode
|
||||
import io.legado.app.utils.putPrefBoolean
|
||||
import io.legado.app.utils.putPrefInt
|
||||
import io.legado.app.utils.putPrefLong
|
||||
import io.legado.app.utils.putPrefString
|
||||
import io.legado.app.utils.removePref
|
||||
import io.legado.app.utils.sysConfiguration
|
||||
@@ -343,12 +341,6 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
appCtx.putPrefInt(PreferKey.threadCount, value)
|
||||
}
|
||||
|
||||
var remoteServerId: Long
|
||||
get() = appCtx.getPrefLong(PreferKey.remoteServerId)
|
||||
set(value) {
|
||||
appCtx.putPrefLong(PreferKey.remoteServerId, value)
|
||||
}
|
||||
|
||||
// 添加本地选择的目录
|
||||
var importBookPath: String?
|
||||
get() = appCtx.getPrefString("importBookPath")
|
||||
|
||||
@@ -20,6 +20,7 @@ import io.legado.app.model.analyzeRule.CustomUrl
|
||||
import io.legado.app.model.localBook.LocalBook
|
||||
import io.legado.app.model.remote.RemoteBook
|
||||
import io.legado.app.model.remote.RemoteBookWebDav
|
||||
import io.legado.app.ui.config.importBookConfig.ImportBookConfig
|
||||
import io.legado.app.ui.widget.components.list.InteractionState
|
||||
import io.legado.app.ui.widget.components.list.ListUiState
|
||||
import io.legado.app.ui.widget.components.list.SelectableItem
|
||||
@@ -68,7 +69,7 @@ data class RemoteBookUiState(
|
||||
val sortKey: RemoteBookSort = RemoteBookSort.Default,
|
||||
val sortAscending: Boolean = false,
|
||||
val servers: List<Server> = emptyList(),
|
||||
val selectedServerId: Long = AppConfig.remoteServerId
|
||||
val selectedServerId: Long = ImportBookConfig.remoteServerId
|
||||
) : ListUiState<RemoteBookItemUi> {
|
||||
override val isSearch: Boolean get() = interaction.isSearchMode
|
||||
override val isLoading: Boolean get() = interaction.isLoading
|
||||
@@ -122,7 +123,7 @@ class RemoteBookViewModel(
|
||||
val selectedIds: Set<String> = emptySet(),
|
||||
val remoteBookWebDav: RemoteBookWebDav? = null,
|
||||
val isDefaultWebdav: Boolean = false,
|
||||
val selectedServerId: Long = AppConfig.remoteServerId
|
||||
val selectedServerId: Long = ImportBookConfig.remoteServerId
|
||||
)
|
||||
|
||||
private val _state = MutableStateFlow(InternalState())
|
||||
@@ -212,13 +213,13 @@ class RemoteBookViewModel(
|
||||
fun initData(onSuccess: () -> Unit) {
|
||||
viewModelScope.launch {
|
||||
try {
|
||||
val webDav = repository.createWebDav(AppConfig.remoteServerId)
|
||||
val webDav = repository.createWebDav(ImportBookConfig.remoteServerId)
|
||||
if (webDav != null) {
|
||||
_state.update {
|
||||
it.copy(
|
||||
remoteBookWebDav = webDav,
|
||||
isDefaultWebdav = false,
|
||||
selectedServerId = AppConfig.remoteServerId
|
||||
selectedServerId = ImportBookConfig.remoteServerId
|
||||
)
|
||||
}
|
||||
onSuccess()
|
||||
@@ -498,7 +499,7 @@ class RemoteBookViewModel(
|
||||
execute {
|
||||
appDb.serverDao.insert(server)
|
||||
}.onSuccess {
|
||||
if (AppConfig.remoteServerId == server.id) {
|
||||
if (ImportBookConfig.remoteServerId == server.id) {
|
||||
initData { loadRemoteBookList() }
|
||||
}
|
||||
}
|
||||
@@ -511,7 +512,7 @@ class RemoteBookViewModel(
|
||||
}
|
||||
|
||||
fun selectServer(serverId: Long) {
|
||||
AppConfig.remoteServerId = serverId
|
||||
ImportBookConfig.remoteServerId = serverId
|
||||
_state.update { it.copy(selectedServerId = serverId, dirList = emptyList()) }
|
||||
initData { loadRemoteBookList() }
|
||||
}
|
||||
|
||||
@@ -20,10 +20,10 @@ import io.legado.app.data.appDb
|
||||
import io.legado.app.data.entities.Server
|
||||
import io.legado.app.databinding.DialogRecyclerViewBinding
|
||||
import io.legado.app.databinding.ItemServerSelectBinding
|
||||
import io.legado.app.help.config.AppConfig
|
||||
import io.legado.app.lib.dialogs.alert
|
||||
//import io.legado.app.lib.theme.backgroundColor
|
||||
//import io.legado.app.lib.theme.primaryColor
|
||||
import io.legado.app.ui.config.importBookConfig.ImportBookConfig
|
||||
import io.legado.app.ui.widget.recycler.VerticalDivider
|
||||
import io.legado.app.utils.applyTint
|
||||
import io.legado.app.utils.setLayout
|
||||
@@ -70,7 +70,7 @@ class ServersDialog : BaseDialogFragment(R.layout.dialog_recycler_view),
|
||||
binding.tvFooterLeft.text = getString(R.string.text_default)
|
||||
binding.tvFooterLeft.visible()
|
||||
binding.tvFooterLeft.setOnClickListener {
|
||||
AppConfig.remoteServerId = DEFAULT_WEBDAV_ID
|
||||
ImportBookConfig.remoteServerId = DEFAULT_WEBDAV_ID
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
binding.tvCancel.visible()
|
||||
@@ -79,7 +79,7 @@ class ServersDialog : BaseDialogFragment(R.layout.dialog_recycler_view),
|
||||
}
|
||||
binding.tvOk.visible()
|
||||
binding.tvOk.setOnClickListener {
|
||||
AppConfig.remoteServerId = adapter.selectServerId
|
||||
ImportBookConfig.remoteServerId = adapter.selectServerId
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
}
|
||||
@@ -109,7 +109,7 @@ class ServersDialog : BaseDialogFragment(R.layout.dialog_recycler_view),
|
||||
inner class ServersAdapter(context: Context) :
|
||||
RecyclerAdapter<Server, ItemServerSelectBinding>(context) {
|
||||
|
||||
var selectServerId: Long = AppConfig.remoteServerId
|
||||
var selectServerId: Long = ImportBookConfig.remoteServerId
|
||||
|
||||
override fun getViewBinding(parent: ViewGroup): ItemServerSelectBinding {
|
||||
return ItemServerSelectBinding.inflate(inflater, parent, false)
|
||||
@@ -164,4 +164,4 @@ class ServersDialog : BaseDialogFragment(R.layout.dialog_recycler_view),
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,4 +24,9 @@ object ImportBookConfig {
|
||||
PreferKey.localBookImportSort,
|
||||
0
|
||||
)
|
||||
|
||||
var remoteServerId by prefDelegate(
|
||||
PreferKey.remoteServerId,
|
||||
0L
|
||||
)
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ fun AppTheme(
|
||||
val composeEngine = ThemeConfig.composeEngine
|
||||
val useMiuixMonet = ThemeConfig.useMiuixMonet
|
||||
val customPrimary = ThemeConfig.cPrimary
|
||||
val customNightPrimary = ThemeConfig.cNPrimary
|
||||
val colorSchemeMode = ThemeResolver.resolveColorSchemeMode(themeModeValue)
|
||||
val miuixColorSchemeMode = remember(themeModeValue, useMiuixMonet) {
|
||||
ThemeResolver.resolveMiuixColorSchemeMode(themeModeValue, useMiuixMonet)
|
||||
@@ -47,21 +48,31 @@ fun AppTheme(
|
||||
appThemeMode,
|
||||
darkTheme,
|
||||
isPureBlack,
|
||||
customPrimary,
|
||||
customNightPrimary,
|
||||
paletteStyleValue,
|
||||
materialVersion
|
||||
) {
|
||||
val customSeedColor = if (darkTheme) customNightPrimary else customPrimary
|
||||
ThemeEngine.getColorScheme(
|
||||
context = context,
|
||||
mode = appThemeMode,
|
||||
darkTheme = darkTheme,
|
||||
isAmoled = isPureBlack,
|
||||
paletteStyle = paletteStyleValue,
|
||||
materialVersion = materialVersion
|
||||
materialVersion = materialVersion,
|
||||
customSeedColor = customSeedColor
|
||||
)
|
||||
}
|
||||
|
||||
val customSeedColor = remember(customPrimary, colorScheme.primary) {
|
||||
if (customPrimary != 0) Color(customPrimary) else colorScheme.primary
|
||||
val customSeedColor = remember(
|
||||
darkTheme,
|
||||
customPrimary,
|
||||
customNightPrimary,
|
||||
colorScheme.primary
|
||||
) {
|
||||
val seed = if (darkTheme) customNightPrimary else customPrimary
|
||||
if (seed != 0) Color(seed) else colorScheme.primary
|
||||
}
|
||||
val themeSeedColor = remember(appThemeMode, customSeedColor, colorScheme.primary) {
|
||||
if (appThemeMode == AppThemeMode.Custom) customSeedColor else colorScheme.primary
|
||||
|
||||
Reference in New Issue
Block a user