@@ -287,7 +287,7 @@ fun OtherConfigScreen(
|
|||||||
SwitchSettingItem(
|
SwitchSettingItem(
|
||||||
title = stringResource(R.string.add_to_text_context_menu_t),
|
title = stringResource(R.string.add_to_text_context_menu_t),
|
||||||
description = stringResource(R.string.add_to_text_context_menu_s),
|
description = stringResource(R.string.add_to_text_context_menu_s),
|
||||||
checked = viewModel.isProcessTextEnabled(),
|
checked = OtherConfig.processText,
|
||||||
onCheckedChange = { viewModel.setProcessTextEnable(it) }
|
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.FileUtils
|
||||||
import io.legado.app.utils.putPrefString
|
import io.legado.app.utils.putPrefString
|
||||||
import io.legado.app.utils.restart
|
import io.legado.app.utils.restart
|
||||||
|
import io.legado.app.utils.toastOnUi
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
@@ -31,6 +32,12 @@ class OtherConfigViewModel : ViewModel() {
|
|||||||
SharedReceiverActivity::class.java.name
|
SharedReceiverActivity::class.java.name
|
||||||
)
|
)
|
||||||
|
|
||||||
|
init {
|
||||||
|
viewModelScope.launch(Dispatchers.IO) {
|
||||||
|
OtherConfig.processText = isProcessTextEnabled()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun isProcessTextEnabled(): Boolean {
|
fun isProcessTextEnabled(): Boolean {
|
||||||
return packageManager.getComponentEnabledSetting(componentName) != PackageManager.COMPONENT_ENABLED_STATE_DISABLED
|
return packageManager.getComponentEnabledSetting(componentName) != PackageManager.COMPONENT_ENABLED_STATE_DISABLED
|
||||||
}
|
}
|
||||||
@@ -41,11 +48,18 @@ class OtherConfigViewModel : ViewModel() {
|
|||||||
} else {
|
} else {
|
||||||
PackageManager.COMPONENT_ENABLED_STATE_DISABLED
|
PackageManager.COMPONENT_ENABLED_STATE_DISABLED
|
||||||
}
|
}
|
||||||
packageManager.setComponentEnabledSetting(
|
viewModelScope.launch(Dispatchers.IO) {
|
||||||
componentName,
|
runCatching {
|
||||||
state,
|
packageManager.setComponentEnabledSetting(
|
||||||
PackageManager.DONT_KILL_APP
|
componentName,
|
||||||
)
|
state,
|
||||||
|
PackageManager.DONT_KILL_APP
|
||||||
|
)
|
||||||
|
OtherConfig.processText = enable
|
||||||
|
}.onFailure {
|
||||||
|
appCtx.toastOnUi(it.localizedMessage)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun clearWebViewData(context: Context) {
|
fun clearWebViewData(context: Context) {
|
||||||
|
|||||||
Reference in New Issue
Block a user