diff --git a/app/src/main/java/io/legado/app/data/dao/ReplaceRuleDao.kt b/app/src/main/java/io/legado/app/data/dao/ReplaceRuleDao.kt index e8a2be048..6a2482d43 100644 --- a/app/src/main/java/io/legado/app/data/dao/ReplaceRuleDao.kt +++ b/app/src/main/java/io/legado/app/data/dao/ReplaceRuleDao.kt @@ -35,6 +35,9 @@ interface ReplaceRuleDao { @Query("update replace_rules set isEnabled = 1 where id in (:ids)") fun enableSection(vararg ids: Long) + @Query("update replace_rules set isEnabled = 0 where id in (:ids)") + fun disableSection(vararg ids: Long) + @Query( """SELECT * FROM replace_rules WHERE isEnabled = 1 AND (scope LIKE '%' || :scope || '%' or scope = null or scope = '')""" diff --git a/app/src/main/java/io/legado/app/ui/replacerule/ReplaceRuleActivity.kt b/app/src/main/java/io/legado/app/ui/replacerule/ReplaceRuleActivity.kt index 7ef6eea0e..40adfd95d 100644 --- a/app/src/main/java/io/legado/app/ui/replacerule/ReplaceRuleActivity.kt +++ b/app/src/main/java/io/legado/app/ui/replacerule/ReplaceRuleActivity.kt @@ -63,6 +63,7 @@ class ReplaceRuleActivity : VMBaseActivity(R.layout.activi R.id.menu_select_all -> adapter.selectAll() R.id.menu_revert_selection -> adapter.revertSelection() R.id.menu_enable_selection -> viewModel.enableSelection(adapter.selectedIds) + R.id.menu_disable_selection -> viewModel.disableSelection(adapter.selectedIds) } return super.onCompatOptionsItemSelected(item) } diff --git a/app/src/main/java/io/legado/app/ui/replacerule/ReplaceRuleViewModel.kt b/app/src/main/java/io/legado/app/ui/replacerule/ReplaceRuleViewModel.kt index d6c874649..0311b58a9 100644 --- a/app/src/main/java/io/legado/app/ui/replacerule/ReplaceRuleViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/replacerule/ReplaceRuleViewModel.kt @@ -45,6 +45,12 @@ class ReplaceRuleViewModel(application: Application) : BaseViewModel(application } } + fun disableSelection(ids: LinkedHashSet) { + execute { + App.db.replaceRuleDao().disableSection(*ids.toLongArray()) + } + } + fun addGroup(group: String) { execute { val sources = App.db.replaceRuleDao().noGroup