From fc7e0d36194db5695937e5e8802481d11a8dcd16 Mon Sep 17 00:00:00 2001 From: niuhb <76513019+niu-hb@users.noreply.github.com> Date: Wed, 18 Dec 2024 19:23:43 +0800 Subject: [PATCH] =?UTF-8?q?rss=E6=94=B6=E8=97=8F=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=89=B9=E9=87=8F=E5=88=A0=E9=99=A4=20(#4444)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/data/dao/RssStarDao.kt | 6 ++++ .../ui/rss/favorites/RssFavoritesActivity.kt | 35 ++++++++++++++++--- app/src/main/res/menu/rss_favorites.xml | 13 ++++++- app/src/main/res/values-es-rES/strings.xml | 1 + app/src/main/res/values-ja-rJP/strings.xml | 1 + app/src/main/res/values-pt-rBR/strings.xml | 1 + app/src/main/res/values-vi/strings.xml | 1 + app/src/main/res/values-zh-rHK/strings.xml | 1 + app/src/main/res/values-zh-rTW/strings.xml | 1 + app/src/main/res/values-zh/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + 11 files changed, 57 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/io/legado/app/data/dao/RssStarDao.kt b/app/src/main/java/io/legado/app/data/dao/RssStarDao.kt index 8a46b0f3e..083b8f6bf 100644 --- a/app/src/main/java/io/legado/app/data/dao/RssStarDao.kt +++ b/app/src/main/java/io/legado/app/data/dao/RssStarDao.kt @@ -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() } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/rss/favorites/RssFavoritesActivity.kt b/app/src/main/java/io/legado/app/ui/rss/favorites/RssFavoritesActivity.kt index 827e54b04..931b7843f 100644 --- a/app/src/main/java/io/legado/app/ui/rss/favorites/RssFavoritesActivity.kt +++ b/app/src/main/java/io/legado/app/ui/rss/favorites/RssFavoritesActivity.kt @@ -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 @@ -53,16 +54,20 @@ class RssFavoritesActivity : BaseActivity() { } 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) } @@ -87,6 +92,28 @@ class RssFavoritesActivity : BaseActivity() { } } + 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) { diff --git a/app/src/main/res/menu/rss_favorites.xml b/app/src/main/res/menu/rss_favorites.xml index 159adcb41..d9f3b4b96 100644 --- a/app/src/main/res/menu/rss_favorites.xml +++ b/app/src/main/res/menu/rss_favorites.xml @@ -1,6 +1,8 @@ + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools" + tools:ignore="AlwaysShowAction"> + + + diff --git a/app/src/main/res/values-es-rES/strings.xml b/app/src/main/res/values-es-rES/strings.xml index d54270221..8c0d773fa 100644 --- a/app/src/main/res/values-es-rES/strings.xml +++ b/app/src/main/res/values-es-rES/strings.xml @@ -30,6 +30,7 @@ Advertencia Editar Borrar + Delete Select Group Borrar todo Reemplazar Reemplazo diff --git a/app/src/main/res/values-ja-rJP/strings.xml b/app/src/main/res/values-ja-rJP/strings.xml index 0de5d951a..e4efe5954 100644 --- a/app/src/main/res/values-ja-rJP/strings.xml +++ b/app/src/main/res/values-ja-rJP/strings.xml @@ -30,6 +30,7 @@ Warning Edit Delete + Delete Select Group Delete all Replace Replacement diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index 752e1dc31..1fe2ca8ea 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -30,6 +30,7 @@ Aviso Editar Excluir + Delete Select Group Excluir tudo Substituir Substituição diff --git a/app/src/main/res/values-vi/strings.xml b/app/src/main/res/values-vi/strings.xml index 21a4c4ac0..59658c4db 100644 --- a/app/src/main/res/values-vi/strings.xml +++ b/app/src/main/res/values-vi/strings.xml @@ -29,6 +29,7 @@ Cảnh báo Sửa đổi Xóa + Xóa nhóm hiện tại Xóa tất cả Chương xuất tùy chỉnh của epub Thay thế diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index 9741f0434..d2324913c 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -28,6 +28,7 @@ 提醒 編輯 刪除 + 刪除當前分組 替換 替換淨化 配置替換淨化規則 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 6c38bd84c..6fe955f23 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -29,6 +29,7 @@ 提醒 編輯 刪除 + 刪除當前分組 刪除所有 取代 取代淨化 diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index 13016360d..e290459c9 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -29,6 +29,7 @@ 提醒 编辑 删除 + 删除当前分组 删除所有 替换 替换净化 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d68f26169..3006f8a02 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -30,6 +30,7 @@ Warning Edit Delete + Delete Select Group Delete all Custom export chapter of epub Replace