修复“文字操作显示搜索”UI没有响应的bug (#1171) @woruteyqi

修复“文字操作显示搜索”的ui没有响应的bug
This commit is contained in:
aoi
2026-05-26 00:48:32 +08:00
committed by GitHub
parent 197039d25a
commit 2d6fc67ac7
2 changed files with 20 additions and 6 deletions
@@ -287,7 +287,7 @@ fun OtherConfigScreen(
SwitchSettingItem(
title = stringResource(R.string.add_to_text_context_menu_t),
description = stringResource(R.string.add_to_text_context_menu_s),
checked = viewModel.isProcessTextEnabled(),
checked = OtherConfig.processText,
onCheckedChange = { viewModel.setProcessTextEnable(it) }
)
@@ -18,6 +18,7 @@ import io.legado.app.ui.config.downloadCacheConfig.DownloadCacheConfig
import io.legado.app.utils.FileUtils
import io.legado.app.utils.putPrefString
import io.legado.app.utils.restart
import io.legado.app.utils.toastOnUi
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
@@ -31,6 +32,12 @@ class OtherConfigViewModel : ViewModel() {
SharedReceiverActivity::class.java.name
)
init {
viewModelScope.launch(Dispatchers.IO) {
OtherConfig.processText = isProcessTextEnabled()
}
}
fun isProcessTextEnabled(): Boolean {
return packageManager.getComponentEnabledSetting(componentName) != PackageManager.COMPONENT_ENABLED_STATE_DISABLED
}
@@ -41,11 +48,18 @@ class OtherConfigViewModel : ViewModel() {
} else {
PackageManager.COMPONENT_ENABLED_STATE_DISABLED
}
packageManager.setComponentEnabledSetting(
componentName,
state,
PackageManager.DONT_KILL_APP
)
viewModelScope.launch(Dispatchers.IO) {
runCatching {
packageManager.setComponentEnabledSetting(
componentName,
state,
PackageManager.DONT_KILL_APP
)
OtherConfig.processText = enable
}.onFailure {
appCtx.toastOnUi(it.localizedMessage)
}
}
}
fun clearWebViewData(context: Context) {