Skip to content

Commit

Permalink
rss收藏增加批量删除 (#4444)
Browse files Browse the repository at this point in the history
  • Loading branch information
niu-hb authored Dec 18, 2024
1 parent 5f392d4 commit fc7e0d3
Show file tree
Hide file tree
Showing 11 changed files with 57 additions and 5 deletions.
6 changes: 6 additions & 0 deletions app/src/main/java/io/legado/app/data/dao/RssStarDao.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,10 @@ interface RssStarDao {

@Query("delete from rssStars where origin = :origin and link = :link")
fun delete(origin: String, link: String)

@Query("delete from rssStars where `group` = :group")
fun deleteByGroup(group: String)

@Query("delete from rssStars")
fun deleteAll()
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import io.legado.app.base.BaseActivity
import io.legado.app.constant.AppLog
import io.legado.app.data.appDb
import io.legado.app.databinding.ActivityRssFavoritesBinding
import io.legado.app.lib.dialogs.alert
import io.legado.app.lib.theme.accentColor
import io.legado.app.utils.gone
import io.legado.app.utils.viewbindingdelegate.viewBinding
Expand Down Expand Up @@ -53,16 +54,20 @@ class RssFavoritesActivity : BaseActivity<ActivityRssFavoritesBinding>() {
}

private fun upGroupsMenu() = groupsMenu?.let { subMenu ->
subMenu.removeGroup(R.id.menu_group_text)
subMenu.removeGroup(R.id.menu_group)
groupList.forEachIndexed { index, it ->
subMenu.add(R.id.menu_group_text, Menu.NONE, index, it)
subMenu.add(R.id.menu_group, Menu.NONE, index, it)
}
}

override fun onCompatOptionsItemSelected(item: MenuItem): Boolean {
super.onCompatOptionsItemSelected(item)
if (item.groupId == R.id.menu_group_text) {
if (item.groupId == R.id.menu_group) {
binding.viewPager.setCurrentItem(item.order)
}else{
when (item.itemId) {
R.id.menu_del_group -> deleteGroup()
R.id.menu_del_all -> deleteAll()
}
}
return super.onCompatOptionsItemSelected(item)
}
Expand All @@ -87,6 +92,28 @@ class RssFavoritesActivity : BaseActivity<ActivityRssFavoritesBinding>() {
}
}

private fun deleteGroup() {
alert(R.string.draw) {
val item = binding.viewPager.currentItem
val group = groupList[item]
setMessage(getString(R.string.sure_del) + "\n" + group + " 分组的收藏")
noButton()
yesButton {
appDb.rssStarDao.deleteByGroup(group)
}
}
}

private fun deleteAll() {
alert(R.string.draw) {
setMessage(getString(R.string.sure_del) + "\n" + "所有收藏")
noButton()
yesButton {
appDb.rssStarDao.deleteAll()
}
}
}

private inner class TabFragmentPageAdapter :
FragmentStatePagerAdapter(supportFragmentManager, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) {

Expand Down
13 changes: 12 additions & 1 deletion app/src/main/res/menu/rss_favorites.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:ignore="AlwaysShowAction">

<item
android:id="@+id/menu_group"
Expand All @@ -11,5 +13,14 @@
<menu />

</item>
<item
android:id="@+id/menu_del_group"
android:title="@string/delete_select_group"
app:showAsAction="never" />

<item
android:id="@+id/menu_del_all"
android:title="@string/delete_all"
app:showAsAction="never" />

</menu>
1 change: 1 addition & 0 deletions app/src/main/res/values-es-rES/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
<string name="draw">Advertencia</string>
<string name="edit">Editar</string>
<string name="delete">Borrar</string>
<string name="delete_select_group">Delete Select Group</string>
<string name="delete_all">Borrar todo</string>
<string name="replace">Reemplazar</string>
<string name="replace_purify">Reemplazo</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-ja-rJP/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
<string name="draw">Warning</string>
<string name="edit">Edit</string>
<string name="delete">Delete</string>
<string name="delete_select_group">Delete Select Group</string>
<string name="delete_all">Delete all</string>
<string name="replace">Replace</string>
<string name="replace_purify">Replacement</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-pt-rBR/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
<string name="draw">Aviso</string>
<string name="edit">Editar</string>
<string name="delete">Excluir</string>
<string name="delete_select_group">Delete Select Group</string>
<string name="delete_all">Excluir tudo</string>
<string name="replace">Substituir</string>
<string name="replace_purify">Substituição</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-vi/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<string name="draw">Cảnh báo</string>
<string name="edit">Sửa đổi</string>
<string name="delete">Xóa</string>
<string name="delete_select_group">Xóa nhóm hiện tại</string>
<string name="delete_all">Xóa tất cả</string>
<string name="custom_export_section">Chương xuất tùy chỉnh của epub</string>
<string name="replace">Thay thế</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-zh-rHK/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<string name="draw">提醒</string>
<string name="edit">編輯</string>
<string name="delete">刪除</string>
<string name="delete_select_group">刪除當前分組</string>
<string name="replace">替換</string>
<string name="replace_purify">替換淨化</string>
<string name="replace_purify_desc">配置替換淨化規則</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-zh-rTW/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<string name="draw">提醒</string>
<string name="edit">編輯</string>
<string name="delete">刪除</string>
<string name="delete_select_group">刪除當前分組</string>
<string name="delete_all">刪除所有</string>
<string name="replace">取代</string>
<string name="replace_purify">取代淨化</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-zh/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<string name="draw">提醒</string>
<string name="edit">编辑</string>
<string name="delete">删除</string>
<string name="delete_select_group">删除当前分组</string>
<string name="delete_all">删除所有</string>
<string name="replace">替换</string>
<string name="replace_purify">替换净化</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
<string name="draw">Warning</string>
<string name="edit">Edit</string>
<string name="delete">Delete</string>
<string name="delete_select_group">Delete Select Group</string>
<string name="delete_all">Delete all</string>
<string name="custom_export_section">Custom export chapter of epub</string>
<string name="replace">Replace</string>
Expand Down

0 comments on commit fc7e0d3

Please sign in to comment.