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 8a46b0f3ebf9..083b8f6bf0bc 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 827e54b04192..931b7843fb9b 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 159adcb41e25..d9f3b4b96ece 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 d54270221e9b..8c0d773fa725 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 0de5d951abce..e4efe5954a2d 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 752e1dc312fe..1fe2ca8eae48 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 21a4c4ac0564..59658c4db6c6 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 9741f0434780..d2324913c5f1 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 6c38bd84cc8d..6fe955f233fe 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 13016360dac8..e290459c925f 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 d68f261691ea..3006f8a02a19 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